]> Cypherpunks repositories - gostls13.git/commitdiff
mime/multipart: unified Part and Reader receiver name
authorWayne Zuo <wdvxdr1123@gmail.com>
Sun, 20 Mar 2022 14:04:43 +0000 (22:04 +0800)
committerDamien Neil <dneil@google.com>
Thu, 31 Mar 2022 22:21:57 +0000 (22:21 +0000)
Change-Id: Ic36dd232f3ea049403715fadec00a74efbf7dc9e
Reviewed-on: https://go-review.googlesource.com/c/go/+/394075
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Trust: Damien Neil <dneil@google.com>

src/mime/multipart/multipart.go

index 81bf722d4ee5fd79df3986c0ab1136e8491b7396..1054e7a4ce16e53a741d6e3f3e2188c30fa82a56 100644 (file)
@@ -149,11 +149,11 @@ func newPart(mr *Reader, rawPart bool) (*Part, error) {
        return bp, nil
 }
 
-func (bp *Part) populateHeaders() error {
-       r := textproto.NewReader(bp.mr.bufReader)
+func (p *Part) populateHeaders() error {
+       r := textproto.NewReader(p.mr.bufReader)
        header, err := r.ReadMIMEHeader()
        if err == nil {
-               bp.Header = header
+               p.Header = header
        }
        return err
 }
@@ -386,36 +386,36 @@ func (r *Reader) nextPart(rawPart bool) (*Part, error) {
 // isFinalBoundary reports whether line is the final boundary line
 // indicating that all parts are over.
 // It matches `^--boundary--[ \t]*(\r\n)?$`
-func (mr *Reader) isFinalBoundary(line []byte) bool {
-       if !bytes.HasPrefix(line, mr.dashBoundaryDash) {
+func (r *Reader) isFinalBoundary(line []byte) bool {
+       if !bytes.HasPrefix(line, r.dashBoundaryDash) {
                return false
        }
-       rest := line[len(mr.dashBoundaryDash):]
+       rest := line[len(r.dashBoundaryDash):]
        rest = skipLWSPChar(rest)
-       return len(rest) == 0 || bytes.Equal(rest, mr.nl)
+       return len(rest) == 0 || bytes.Equal(rest, r.nl)
 }
 
-func (mr *Reader) isBoundaryDelimiterLine(line []byte) (ret bool) {
+func (r *Reader) isBoundaryDelimiterLine(line []byte) (ret bool) {
        // https://tools.ietf.org/html/rfc2046#section-5.1
        //   The boundary delimiter line is then defined as a line
        //   consisting entirely of two hyphen characters ("-",
        //   decimal value 45) followed by the boundary parameter
        //   value from the Content-Type header field, optional linear
        //   whitespace, and a terminating CRLF.
-       if !bytes.HasPrefix(line, mr.dashBoundary) {
+       if !bytes.HasPrefix(line, r.dashBoundary) {
                return false
        }
-       rest := line[len(mr.dashBoundary):]
+       rest := line[len(r.dashBoundary):]
        rest = skipLWSPChar(rest)
 
        // On the first part, see our lines are ending in \n instead of \r\n
        // and switch into that mode if so. This is a violation of the spec,
        // but occurs in practice.
-       if mr.partsRead == 0 && len(rest) == 1 && rest[0] == '\n' {
-               mr.nl = mr.nl[1:]
-               mr.nlDashBoundary = mr.nlDashBoundary[1:]
+       if r.partsRead == 0 && len(rest) == 1 && rest[0] == '\n' {
+               r.nl = r.nl[1:]
+               r.nlDashBoundary = r.nlDashBoundary[1:]
        }
-       return bytes.Equal(rest, mr.nl)
+       return bytes.Equal(rest, r.nl)
 }
 
 // skipLWSPChar returns b with leading spaces and tabs removed.