Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(746)

Delta Between Two Patch Sets: src/pkg/net/textproto/reader.go

Issue 5272049: code review 5272049: textproto: prevent long lines in HTTP headers from caus... (Closed)
Left Patch Set: diff -r dd81822c18a9 https://go.googlecode.com/hg/ Created 12 years, 5 months ago
Right Patch Set: diff -r 3213129c689b https://go.googlecode.com/hg/ Created 12 years, 5 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | src/pkg/net/textproto/reader_test.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 // Copyright 2010 The Go Authors. All rights reserved. 1 // Copyright 2010 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 package textproto 5 package textproto
6 6
7 import ( 7 import (
8 "bufio" 8 "bufio"
9 "bytes" 9 "bytes"
10 "io" 10 "io"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 if line != nil { 43 if line != nil {
44 buf := make([]byte, len(line)) 44 buf := make([]byte, len(line))
45 copy(buf, line) 45 copy(buf, line)
46 line = buf 46 line = buf
47 } 47 }
48 return line, err 48 return line, err
49 } 49 }
50 50
51 func (r *Reader) readLineSlice() ([]byte, os.Error) { 51 func (r *Reader) readLineSlice() ([]byte, os.Error) {
52 r.closeDot() 52 r.closeDot()
53 » var fullLine []byte 53 » var line []byte
54 for { 54 for {
55 » » line, isPrefix, err := r.R.ReadLine() 55 » » l, more, err := r.R.ReadLine()
56 » » if isPrefix { 56 » » if err != nil {
57 » » » fullLine = append(fullLine, line...) 57 » » » return nil, err
58 » » } else { 58 » » }
59 » » » if fullLine == nil { 59 » » // Avoid the copy if the first call produced a full line.
60 » » » » return line, err 60 » » if line == nil && !more {
61 » » » } else { 61 » » » return l, nil
62 » » » » fullLine = append(fullLine, line...) 62 » » }
63 » » » » return fullLine, err 63 » » line = append(line, l...)
64 » » » } 64 » » if !more {
65 » » } 65 » » » break
66 » } 66 » » }
67 » panic("unreachable") 67 » }
68 » return line, nil
68 } 69 }
69 70
70 // ReadContinuedLine reads a possibly continued line from r, 71 // ReadContinuedLine reads a possibly continued line from r,
71 // eliding the final trailing ASCII white space. 72 // eliding the final trailing ASCII white space.
72 // Lines after the first are considered continuations if they 73 // Lines after the first are considered continuations if they
73 // begin with a space or tab character. In the returned data, 74 // begin with a space or tab character. In the returned data,
74 // continuation lines are separated from the previous line 75 // continuation lines are separated from the previous line
75 // only by a single space: the newline and leading white space 76 // only by a single space: the newline and leading white space
76 // are removed. 77 // are removed.
77 // 78 //
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 if upper && 'a' <= v && v <= 'z' { 536 if upper && 'a' <= v && v <= 'z' {
536 a[i] = v + 'A' - 'a' 537 a[i] = v + 'A' - 'a'
537 } 538 }
538 if !upper && 'A' <= v && v <= 'Z' { 539 if !upper && 'A' <= v && v <= 'Z' {
539 a[i] = v + 'a' - 'A' 540 a[i] = v + 'a' - 'A'
540 } 541 }
541 upper = v == '-' 542 upper = v == '-'
542 } 543 }
543 return string(a) 544 return string(a)
544 } 545 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b