-
Notifications
You must be signed in to change notification settings - Fork 11
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
FixInvalidDayOffsetPreprocessor: Allow DURATION as value #182
FixInvalidDayOffsetPreprocessor: Allow DURATION as value #182
Conversation
2e466f8
to
f5e56f6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume this is based on a real issue? Which one?
Can we require a property (or a list of properties which may have a DURATION
) or at least ;VALUE=
?
This pre-processor is a very risky and off-the-wall way to fix things and should be used in the most minimal way. For instance, I always fear that some plaintext may contain exactly this content and then be modified …
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything looks good, makes sense. I didn't know that there was such a property. Should we somehow use it at some point? I mean, we can only fetch new data if necessary knowing that it only updates once a day, for example.
This one: bitfireAT/icsx5#462
Yes, that's why I tried to relax the regex as little as possible.
I will try to narrow it down some more in a sensible way. |
Updated. I believe DURATION can only occur as value of the following properties. RFC 5545
RFC 7986
Since TRIGGER never occurs as a value for any of the properties (like DURATION does), it's a bit weird to have it in the regex as well, but I think separating it might make the regex unnecessarily complex. |
lib/src/main/kotlin/at/bitfire/ical4android/validation/FixInvalidDayOffsetPreprocessor.kt
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Working fine.
I have suggestions for method names in tests.
lib/src/test/kotlin/at/bitfire/ical4android/validation/FixInvalidDayOffsetPreprocessorTest.kt
Outdated
Show resolved
Hide resolved
lib/src/test/kotlin/at/bitfire/ical4android/validation/FixInvalidDayOffsetPreprocessorTest.kt
Outdated
Show resolved
Hide resolved
3cc4fa6
to
e55de0a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have changed the test so that it asserts what is expected (and not what is not expected, which was confusing for me).
And one question :)
lib/src/main/kotlin/at/bitfire/ical4android/validation/FixInvalidDayOffsetPreprocessor.kt
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for making this complicated… but I think it's worth to fully understand the details of this regex and class and what they do, otherwise it could make unexpected problems.
lib/src/main/kotlin/at/bitfire/ical4android/validation/FixInvalidDayOffsetPreprocessor.kt
Outdated
Show resolved
Hide resolved
No worries. I don't like working with regex, but you are totally right. We should not slip up here. I did not fully understand how the non-capturing groups work. I expected them to be excluded from the whole match, but alas they are not and we need to use the list of capturing groups like you say. I changed the regex to capture only the duration in a capturing group, while ignoring the begining of the string, so problems as with the "CAPTION" scenario should not arise:
I also tried to make the code as explicit as possible with many comments. The first capturing group always contains the whole match. The second match group ( In the best case we would also add another edge case test for the "CAPTION" scenario. If we are worried about unexpected issues, more tests clamping down on the expected behaviour are always nice to have. I don't see how we can do that though, since "CAPTION" is not a relevant property here as it can not have a duration value. The alternative would be to drop all the non-capturing groups and simply write a comment about replacing "PT" with "T" in the whole capture.
AFAIK |
To illustrate what I mean: I have now used Tests are OK; please have a final look and then I'll merge if it's OK for you. |
Oh, so the match group has a range as well ... Yeah, no. I did not get that from your description. But looks good to me like this. Much shorter 👍 |
Allow DURATION as value in FixInvalidDayOffsetPreprocessor so that it will be found and the actual duration value can be fixed if invalid.
Reported in ICSx5: bitfireAT/icsx5#462