Code Monkey home page Code Monkey logo

go-pop3's People

Contributors

thecreeper avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

go-pop3's Issues

ReadLines() does not handle dot stuffing correctly

I discovered that reading a mail message using c.ReadLines() is incorrect: while the function interprets a single . as the end of message, it does not un-escape the dot when a line begins with a dot.

Dropping in the code from net/textproto helps:

diff --git i/pop3.go w/pop3.go
index de0727a..cd44007 100644
--- i/pop3.go
+++ w/pop3.go
@@ -72,10 +72,13 @@ func (c *Client) ReadLines() (lines []string, err error) {
 			return nil, err
 		}
 
-		// Look for a dot to indicate the end of a message
-		// from the server.
-		if line == "." {
-			break
+		// from go1.20.5/src/net/textproto/reader.go#L298:
+		// Dot by itself marks end; otherwise cut one dot.
+		if len(line) > 0 && line[0] == '.' {
+			if len(line) == 1 {
+				break
+			}
+			line = line[1:]
 		}
 		lines = append(lines, line)
 	}

I suspect that c.Retr() is similarly buggy because it uses mail.ReadMessage, which does use net/textproto, but does not call its DotReader() function, but I haven’t verified.

Filing this issue mostly so that other users are aware of the issue.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.