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
Bug in Evaluator.AttributeWithValue #474
Comments
Any chance we may get it in 1.8.2 release? |
I added following test to ElementsTest in the latest code:
It is working perfectly fine. |
I ran your test code in 1.8.1 and master branches. assertEquals(1, els.size()) throws AssersionError. java.lang.AssertionError: expected:[1] but was:[0] |
It is working fine for me, even after I changed the system locale to Turky. Here is the output:
|
With locale set to "tr-TR" the test will pass. The test should pass irrespective of locale. |
The test @jasdeep wrote works for me to. My locale is set to us_US. @savatgithub can you give a junit test case, your java version, and your locale, so we can see why you're able to repro but others aren't (I.e me, jasdeep, and try.jsoup) |
@jhy the test code is same as in the original post which @jasdeep converted to a junit test code. My Java version is 1.7.0_01, system locale is us_US. Dev environment is Eclipse on Windows 8.1. can you see if you're using Java 6 or 7? http://grepalex.com/2013/02/14/java-7-and-the-dotted--and-dotless-i/ |
@jhy additionally can you run the following test code on your dev environment. These should assert. |
@savatgithub
|
@jasdeep i can reproduce from command line outside of eclipse. What is your OS? |
@savatgithub It is Windows 7. |
@savatgithub Got it reproduced on Java 8, worked fine with Java 6 |
Shouldn't it be the other way around? I.e. it was incorrectly
transliterated to "i" using .toLowercase in 1.6, and fixed in 1.7 / 1.8
(which is why I didn't see the issue when I tried to repro)?
Anyway I think it's clear from this investigation there's an issue in Java
that needs a workaround for different versions, and we can just supply a
normalizing locale to fix them
Thanks,
Jonathan
|
This is fixed with @cketti's (super robust) commit. Thanks! |
It should print "elements=1" but prints "elements=0".
Bug is in Evaluator.AttributeWithValue. https://github.com/jhy/jsoup/blob/master/src/main/java/org/jsoup/select/Evaluator.java. Constructor stores the "value" in lower case and AttributeWithValue.matches compares it using equalsIgnoreCase. This would fail for some characters unless proper locale is used in toLowerCase. For example:
Since the intent is to compare case-insensitive, a fix might be to not use equalsIgnoreCase in AttributeWithValue.matches but use equal and toLowerCase. That is:
AttributeWithValueNot may suffer from the same issue.
For some reason, it works on http://try.jsoup.org. That might be a separate issue as to why it works there.
The text was updated successfully, but these errors were encountered: