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

TextToFlowed doesn't generate valid flowed text #580

Closed
jessicah opened this issue Jun 8, 2020 · 4 comments
Closed

TextToFlowed doesn't generate valid flowed text #580

jessicah opened this issue Jun 8, 2020 · 4 comments
Labels
bug Something isn't working

Comments

@jessicah
Copy link

jessicah commented Jun 8, 2020

Describe the bug
Using TextToFlowed to generate format=flowed output, it doesn't appear to generate valid output. Lines appear to be space-stuffed at the beginning.

Platform (please complete the following information):

  • OS: Windows
  • .NET Runtime: Core
  • .NET Framework: .NET Core 3.1
  • MimeKit Version: 2.6.0

To Reproduce
Steps to reproduce the behavior:

var flowedConverter = new MimeKit.Text.TextToFlowed();
var flowedText = flowedConverter.Convert(textWithParagraphsInSingleLines);

Expected behavior
Text should be correctly flowed with long lines broken up with proper line continuations.

@jessicah
Copy link
Author

jessicah commented Jun 8, 2020

I think it might be this line: https://github.com/jstedfast/MimeKit/blob/master/MimeKit/Text/TextToFlowed.cs#L133

As it doesn't increment the index, the trailing space after splitting the line is processed again on subsequent calls to GetFlowedLine: https://github.com/jstedfast/MimeKit/blob/master/MimeKit/Text/TextToFlowed.cs#L130.

I believe the correct thing to do here is to increment index until a non-space character is encountered.

@jstedfast
Copy link
Owner

Do you happen to have a test case that I can use to see the issue and verify that it's fixed once it's fixed?

@jstedfast jstedfast added the bug Something isn't working label Jun 8, 2020
@jstedfast
Copy link
Owner

jstedfast commented Jun 9, 2020

FWIW, so that we are all on the same page with regards to expected behavior, the specification for format=flowed is: https://tools.ietf.org/html/rfc3676

I just added a test case (it's split between 2 commits because I can't get VS2019 to run the unit tests for some reason so had to commit a partial test in order to complete it on my MacBook w/ VS4Mac which runs them fine).

b4a92eb adds the expected output which I added a comment to which exposes at least 1 bug but I don't think that's the bug that you are hitting.

Secondly, keep in mind that according to my docs for TextToFlowed, the output is designed for format=flowed; delsp=yes which has a different expected output than delsp=no.

Maybe TextToFlowed should be more configurable to dictate what delsp behavior to use.

I saw your fork & fix and I'm not sure that your fix is correct because because if you set delsp=yes, then your fix looks like it would break FlowedToText when DeleteSpace=true.

jstedfast added a commit that referenced this issue Jun 13, 2020
Fixes issue #580 (I think?)
@jstedfast
Copy link
Owner

I'm not sure if my fix solves your issue, but if I understand the issue you described correctly, then it does. It also fixes other bugs that I found.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants