Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to handle trailing newlines? #67

Open
trestletech opened this issue Aug 23, 2017 · 2 comments
Open

How to handle trailing newlines? #67

trestletech opened this issue Aug 23, 2017 · 2 comments

Comments

@trestletech
Copy link
Contributor

If a field has a trailing newline, it can be marshaled as a separate paragraph.

I see that in parsing you take special precautions for the case of a line that is a single space/tab followed by a period (https://github.com/paultag/go-debian/blob/master/control/parse.go#L228-L230) to treat that as an empty line. But when you marshal a property that has trailing newlines you don't currently take any special precautions.

Meaning that when I go to marshal an array of objects I can end up with:

ID: 1
Description: Description here
 and continues here.

Name: Object1

ID: 2
Description: Single-line desc
Name: Object2

which now gets improperly parsed.

Would you argue that it's the client's responsibility to prune such trailing newlines before serializing? Or would you be open to a PR that alters the serialization behavior to take advantage of that special case mention above and translate trailing newlines to include a leading whitespace and a period so that it gets rendered like so:

ID: 1
Description: Description here
 and continues here.
 .
Name: Object1

ID: 2
Description: Single-line desc
Name: Object2

I believe that could be parsed properly.

@paultag
Copy link
Owner

paultag commented Aug 24, 2017

Ah, cool! Nice bug. Yeah, the marshal code should handle this right, if I give it the raw text of a document, it shouldn't generate something invalid. Nice catch!

@paultag
Copy link
Owner

paultag commented Aug 24, 2017

I wonder if we can use the DotWriter from SMTP or something to help with this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants