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

Unescape Value-Type: TEXT in Golang Model #91

Merged
merged 9 commits into from
May 30, 2024
Merged

Conversation

brenank
Copy link
Contributor

@brenank brenank commented May 20, 2024

Previously, the property convenience methods Set...(someStrValue) expected someStrValue to be an unescaped string, getting the value would require calling ical.FromText(event.GetProperty(ical.ComponentProperty...).Value)

While adding convenience functions for Get...() was an option, the specification states that this should be applied to all property values with a value-type of "TEXT", which would require a lot of Set... & Get... convenience functions. It seemed cleaner to move the FromText/ToText calls into the de/serialization logic, which would clean up the public API to be consistent as entirely unescaped.

This also adds an additional loop & sort of all Property Parameters to keep the serialization stable. Mainly added for testing purposes, but if this is not desired, the compare serialized -> deserialized -> serialized tests could be removed.

Also corrected a small serialization bug, where VFREEBUSY properties were being serialized out as VBUSY.

See: https://datatracker.ietf.org/doc/html/rfc5545#section-3.3.11

@brenank brenank force-pushed the master branch 3 times, most recently from 0a707b2 to dc3ed8d Compare May 20, 2024 22:22
@brenank brenank marked this pull request as ready for review May 20, 2024 22:24
@arran4 arran4 self-requested a review May 21, 2024 01:18
@arran4
Copy link
Owner

arran4 commented May 21, 2024

@brenank Test failings are not yours it seems that the action is failing. I will try again in 24 hours, if it doesn't work then I will dig in and fix the tests.

@brenank
Copy link
Contributor Author

brenank commented May 21, 2024

@brenank Test failings are not yours it seems that the action is failing. I will try again in 24 hours, if it doesn't work then I will dig in and fix the tests.

Ah seems it failed the linting job. Created a fix.

@brenank
Copy link
Contributor Author

brenank commented May 21, 2024

Yeah it seems the GHAs for setup-go are failing. Might be worth pinning it to the version listed in go.mod: https://github.com/actions/setup-go?tab=readme-ov-file#getting-go-version-from-the-gomod-file
And maybe rev'ing to the latest version.

@arran4
Copy link
Owner

arran4 commented May 21, 2024

Happy for you to add that to the PR (or a separate if you want.) Otherwise I will dig in when I have time.

@brenank brenank force-pushed the master branch 4 times, most recently from 1c9036c to ec40c25 Compare May 21, 2024 04:16
@brenank
Copy link
Contributor Author

brenank commented May 21, 2024

Happy for you to add that to the PR (or a separate if you want.) Otherwise I will dig in when I have time.

Created a separate PR #92. Rebased this PR on top of those changes.

@arran4
Copy link
Owner

arran4 commented May 21, 2024

Let's sort out the actions PR first.

@brenank brenank force-pushed the master branch 3 times, most recently from aa56c89 to bd0b9a7 Compare May 21, 2024 06:33
@arran4
Copy link
Owner

arran4 commented May 21, 2024

I take it #92 is in this one too?

brenank added 5 commits May 21, 2024 08:02
This is a breaking change. Property.Value of value-type: TEXT is now unescaped in the deserialized model. Previously, this was escaped.
@brenank
Copy link
Contributor Author

brenank commented May 21, 2024

I take it #92 is in this one too?

Yeah It did, I just rebased on top of master, so it removed the commits from #92 for easier review.

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.

Sorry it took so long. The sort really threw me off.

A couple suggestions, and .. the sort.

.gitignore Outdated
@@ -1 +1,2 @@
/.idea/
actual
Copy link
Owner

Choose a reason for hiding this comment

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

I don't mind extra entries but this one seems like it's your side only, perhaps add it to your $PROJECT/.git/info/exclude list rather than $PROJECT/.gitignore ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The test outputs this folder if it fails for easy comparison and updating of the expected values. It should never be checked in so I figured it should be added to project level gitignore.

I can scope it down to be more specific if desired.

Copy link
Owner

Choose a reason for hiding this comment

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

I have no issue with the line being there, however it should be

/actual

so that it isn't applied throughout the entire directory structure. Just we aren't generating any runtime data for actual as far as I can tell so it might have been better in the .git/info/exclude file (which is per repo and local only.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

scoped this more narrowly, since this does create files during runtime (only when running serialization test & only if there are failures)

property.go Outdated Show resolved Hide resolved
calendar_serialization_test.go Outdated Show resolved Hide resolved
calendar_serialization_test.go Outdated Show resolved Hide resolved
property.go Show resolved Hide resolved
@brenank
Copy link
Contributor Author

brenank commented May 24, 2024

All good! I'll make the suggested updates when I get some time.

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 6591742 into arran4:master May 30, 2024
16 checks passed
@arran4
Copy link
Owner

arran4 commented May 30, 2024

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

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.

2 participants