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

Fix various text escaping issues #86

Merged
merged 3 commits into from
Feb 14, 2024
Merged

Conversation

frereit
Copy link
Contributor

@frereit frereit commented Feb 9, 2024

  1. Make sure that text escapes are handled correctly in all cases.
  2. Normalize property.Value to always contain unescaped values. They are escaped when serializing, and unescaped when parsing.

This commit normalizes the meaning of "property.Value". It always contains an unserialized property value.
Previously, property params were deserialized when parsing but not serialized again.
Previously, ";" was incorrectly escaped. First, ";" was replaced by
"\;". Then, the backslash was escpaed to "\\", resulting in "\\;".

Now, we first escape all backslashes and then escape other characters.
@arran4
Copy link
Owner

arran4 commented Feb 10, 2024

@frereit Do you have an example / test of where this fails in the current implementation?

@frereit
Copy link
Contributor Author

frereit commented Feb 13, 2024

I have added a test that is fixed by 0f8a325.

3ffa099 is not directly fixing a bug but simply normalizing when escaping happens. This is so that these two statements have the same effect:

event.SetProperty(ics.ComponentPropertyDescription, "D:escription")
event.SetDescription("D:escription")

which they currently do not have, because SetDescription performs escaping, while SetProperty does not.

@frereit
Copy link
Contributor Author

frereit commented Feb 13, 2024

By the way, this closes #68

arran4
arran4 previously approved these changes Feb 13, 2024
@arran4 arran4 linked an issue Feb 13, 2024 that may be closed by this pull request
@arran4
Copy link
Owner

arran4 commented Feb 13, 2024

Thanks. Running tests now.

@arran4
Copy link
Owner

arran4 commented Feb 13, 2024

Seems there is a white space issue in the test on Mac OS X

@frereit
Copy link
Contributor Author

frereit commented Feb 14, 2024

I think the issue was that the order of property parameters was non-deterministic. I've removed the unneccessary property parameter, the test should now be fixed. It's a bit difficult to debug because the test passes on my local machine.

Copy link
Owner

@arran4 arran4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@arran4 arran4 merged commit 542d6e5 into arran4:master Feb 14, 2024
13 checks passed
@arran4
Copy link
Owner

arran4 commented Feb 14, 2024

I think the issue was that the order of property parameters was non-deterministic. I've removed the unneccessary property parameter, the test should now be fixed. It's a bit difficult to debug because the test passes on my local machine.

I can believe that.. Although I thought I had written this with very limited use of maps as I wanted it to be bidirectional and deterministic..

It didn't show up in tests and I can't see how this would create more nondeterministic behavior, plus only showing up on mac is a bit odd.

One earlier PR did add some fuzzing. I will have to make some time to do more advanced testing it looks like.

@arran4
Copy link
Owner

arran4 commented Feb 14, 2024

https://github.com/arran4/golang-ical/releases/tag/v0.2.5

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

Successfully merging this pull request may close these issues.

Already escaped symbols get double escaped
2 participants