-
-
Notifications
You must be signed in to change notification settings - Fork 903
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
CRuby/JRuby inconsistent behavior aliasing the default namespace #940
Comments
I think I found the problem, The hashCode method in NokogiriNamespaceCache does not take negative values into account when generating a hash code for a prefix and href. This is the method in question;
the hashCode() method from Object returns a integer. This int may be negative and will be up-converted to a long as a negative number , filling all of the leading bits in as 1. We can look at an example and see what this does to actually creating the hashCode to return.
When these values get converted to a long the binary for "ns:fruit" ends up looking like this.
Performing any kind of a bitwise or on this value is going to cause the entire leading set of bits to filled with 1s, which is not what is expected to happen. A simple solution to this is to simply mask off the leading bytes to ensure that the leading bits will be filled with zeros instead.
|
…parklemotion#940. This allows for namespace prfixes to the redeclared at an element level, allows for default namespaces to be redeclared at an element level and fixes issues related to adding namepsaces delcarations on the document for use in xpath calls
…parklemotion#940. This allows for namespace prfixes to the redeclared at an element level, allows for default namespaces to be redeclared at an element level and fixes issues related to adding namepsaces delcarations on the document for use in xpath calls
…parklemotion#940. This allows for namespace prfixes to the redeclared at an element level, allows for default namespaces to be redeclared at an element level and fixes issues related to adding namepsaces delcarations on the document for use in xpath calls
Yes. Also, I need to look at related pull request. I think I have time to do something this week or so. |
This bug has been fixed by the commit 742751a Thanks for reporting the bug. |
There is inconsistent behavior between Cruby and Jruby when aliasing the default namespace for node. I created a test to highlight the difference.
Executing this under Cruby the test will pass. The output under JRuby however will be the following.
This can cause issues when dealing with xpath statments: Take the following example
This creates and apple element in the ns:fruit namespace. Now without being able to alias the default namespace we have no way to execute xpath statements on it based on the structure of the document. This behavior is the same in both C Ruby and JRuby
Now if we add a namespace alias for the default namespace we can do this in C Ruby.
Trying to do this in JRuby however does not work
Furthermore , if we look at the namespaces for the document the alias that we just added is not there in JRuby.
But oddly if we look at the document itself it is there.
The text was updated successfully, but these errors were encountered: