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

Error in line folding algorithm #693

Open
ssratkevich opened this issue Jan 16, 2025 · 1 comment · May be fixed by #695
Open

Error in line folding algorithm #693

ssratkevich opened this issue Jan 16, 2025 · 1 comment · May be fixed by #695
Labels

Comments

@ssratkevich
Copy link

According to Section 3.1 of RFC-5545 line:

Lines of text SHOULD NOT be longer than 75 octets, excluding the line break.

Octet is not a character in C# cause of C# char is 2 byte (16 bit = 2 octets) length, but 1 octet is 1 byte.
So, you must firstly get the byte representation of a string, say with utf8 encoder, after that it's allowed to do the folding.
You can also pick up another strategy except one you choose now.

@axunonb axunonb added the bug label Jan 16, 2025
@axunonb
Copy link
Collaborator

axunonb commented Jan 16, 2025

Thanks for pointing this out. It's rather about the UTF-8 representation when serializing than the char representation in C# to be precise. The UTF-8 encoder is a "must use" because of Section 8.1 of RFC 5545. As we're currently quite busy fixing a couple of other issues of ica.lnet, we'd be more than happy to welcome a PR. Could you give us a helping hand?

it's about the method TextUtil.FoldLines(string) that requires the fix.

axunonb added a commit to axunonb/ical.net that referenced this issue Jan 18, 2025
- Update line folding to use StringBuilder and ArrayPool<char> for better performance and memory efficiency.
- Ensure compliance with RFC 5545 by handling multi-byte characters correctly.
- Add System.Buffers package for netstandard2.0 target framework.

Resolves ical-org#693
@axunonb axunonb linked a pull request Jan 18, 2025 that will close this issue
axunonb added a commit to axunonb/ical.net that referenced this issue Jan 18, 2025
- Update line folding to use StringBuilder and ArrayPool<char> for better performance and memory efficiency.
- Ensure compliance with RFC 5545 by handling multi-byte characters correctly.
- Add System.Buffers package for netstandard2.0 target framework.

Resolves ical-org#693
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants