-
-
Notifications
You must be signed in to change notification settings - Fork 172
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
[RFC] Allow =
in parameter values.
#207
Conversation
654e079
to
63025ee
Compare
Regarding the test introduced in #204 one could argue to remove this test now. Its only purpose was to pinpoint a problem, which is getting fixed by this commit making this test obsolete. However, I would rather argue that the test should stay. I would therefore suggest to change line 20 into This second approach would then verify that:
|
I have modified the old test and added a new one that tests the fix introduced in #204. |
63025ee
to
f3a3dd6
Compare
Looks like I forgot to push those changes (done now). The failing test is pypy3, which we currently do not support, I have opened #206 to deal with that. |
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.
q_split
logic looks good to me
for event in cal.walk('vevent'): | ||
self.assertEqual(len(event.errors), 0, 'Got too many errors') | ||
|
||
except UnicodeEncodeError as e: |
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.
Why catch the error at all?
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.
Honestly: no idea, I've just re-used the old test, but sure, we can remove it.
605ec2c
to
91a1648
Compare
I removed those try/excepts. |
LGTM
…On Wed, Jan 04, 2017 at 05:20:34PM -0800, Christian Geier wrote:
I removed those try/excepts.
--
You are receiving this because you commented.
Reply to this email directly or view it on GitHub:
#207 (comment)
|
That should be ok. Back then, the except was used to let the test fail. |
Putting it on my TODO list |
"=" is a SAFECHAR and should be allowed in unquoted values, so this is indeed a bug. |
a4137f1
to
a9e14e3
Compare
This causes old PRs to add the changelog entry to already released versions. It happened to me while rebasing collective#207
Apparently I can push commits to this PR, so I fixed this!
…On Thu, Jan 19, 2017 at 03:03:28AM -0800, Lennart Regebro wrote:
"=" is a SAFECHAR and should be allowed in unquoted values, so this is indeed a bug.
Only comment I have is that passing in maxsplit=0 doesn't return the expected result (no splits). It's a sufficiently silly case that you can choose not to support it.
--
You are receiving this because you commented.
Reply to this email directly or view it on GitHub:
#207 (comment)
|
a9e14e3
to
5b875e8
Compare
Well, maxsplit=0 should reasonably not split at all. maxsplit=0 being the same as maxsplit=1 is even more confusing than it being the same as maxsplit=-1. :-) |
|
Ah, I see it fails in cases where there's nothing between the separator. |
5b875e8
to
0b88c90
Compare
@regebro so that was a bug, fixed! |
def test_q_split_bin(self): | ||
from ..parser import q_split | ||
for s in ('X-SOMETHING=ABCDE==', ',,,'): | ||
for maxsplit in range(3): |
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'd suggest range(-1, 3)
here.
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.
done
Because it doesn't split if we are in between "s.
Quoting Stanislav Láznička (2017-01-19 18:49:27)
… I hope I am not missing anything but is the `q_split()` function really needed? Why not either use the Python's native `str.split()` or if we really really don't like the "." notation, map it in a function like this:
```python
def q_split(st, sep=",", max_split=0):
st.split(sep, max_split)
```
The `q_split()` function looks like a hack from Python-prehistoric times to me.
--
You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub:
#207 (comment)
|
@geier Thank you, I found that out right after I wrote that comment so I removed it :) Been in work for too long today. |
Test if we support base64 encoded binary data in parameter values. | ||
""" | ||
directory = os.path.dirname(__file__) | ||
data = open(os.path.join(directory, 'x_location.ics'), 'rb').read() |
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.
Please use a context manager here to fix the resource warning.
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.
That's the way it's done throughout the test suite. I believe it's better to be consistent than to be right (in this case).
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.
It's no longer done this way, see #213
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.
oh, it isn't any more... alright, will fix
This conflicts with master, otherwise LGTM |
8ebe85f
to
db31584
Compare
done |
db31584
to
d3f9afe
Compare
I can force push into the branch, and your approval doesn't get auto-revoked!? |
3594e97
to
c37b983
Compare
anybody got any idea why python 2.6 now fails on travis with
? |
As this group maintained, I'm not going to merge this myself, but I'd be grateful if somebody else would do it or voice their concerns. I believe the current failure with python2.6 can safely be ignored, as it fails on master, too 😬 |
Any update on this? Looks ready, right? |
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.
Yeah, though we should have multiple approvers
@regebro could you take a quick look at this again? |
Some parameter values (e.g., BASE64 encoded binary data often ends with one or two equal signs) may contain an equal sign (`=`). The current implementation splits key-value pairs at all equal signs, which leads to errors. Especially icalendar files generated by Apple's software often feature BASE64 encoded binary data in parameter values. This patch introduces a new parameter `maxsplit` to icalendar.parser.q_split() which works similar as python's string.split(sep, maxsplit) which we then use to split parameter key-value pairs only at the first equal sign. This patch fixes collective#197.
The fix for collective#197 makes the test data used for testing the error messages for broken properties (which was valid data) work with icalendar, we therefor need a new test with actually invalid data.
Thanks everyone who contributed! |
Some parameter values (e.g., BASE64 encoded binary data often ends with one or two equal signs) may contain an equal sign (
=
). The current implementation splits key-value pairs at all equal signs, which leads to errors. Especially icalendar files generated by Apple's software often feature BASE64 encoded binary data in parameter values.This patch introduces a new parameter
maxsplit
to icalendar.parser.q_split() which works similar as python's string.split(sep, maxsplit) which we then use to split parameter key-value pairs only at the first equal sign.This patch fixes #197.