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

Add failing test case for Nokogiri::XML::Node#content inconsistency between Java and C #794

Conversation

benlangfeld
Copy link
Contributor

C implementation includes content of child nodes recursively, Java does not.

@benlangfeld
Copy link
Contributor Author

Any guidance on how I should approach fixing this would be most appreciated.

@jvshahid
Copy link
Member

sorry for the late response. I'll take a look and get back to you shortly.

@jvshahid
Copy link
Member

Can you explain what's wrong with the test in commit 0e43632, i mean what are you trying to test ?

@benlangfeld
Copy link
Contributor Author

Note that this is, I hope, the last thing blocking my Nokogiri-dependent stuff from all passing on JRuby. I would love to get this in to 1.5.6, assuming that is coming soon. It'll be beers all round at that point :)

@benlangfeld
Copy link
Contributor Author

On JRuby, node.content returns "I <3 nachos". On libxml it returns "I ". A similar thing can be seen in the rendered XML. It seems libxml is assuming all instances of "<" mean there's an XML element coming and doesn't escape correctly.

@jvshahid
Copy link
Member

That's what I thought. I think in this case the C implementation is doing the right thing, the << method on nodes accept markup, which explains why everything after the < was dropped. This is just the way libxml handles invalid markup.

@benlangfeld
Copy link
Contributor Author

So how then do I append a string containing "<"? I can't do node.content += "<". That would work, other than the issue in the other test here where on libxml #content walks all children (which I believe is correct, though perhaps this should be optional).

@jvshahid
Copy link
Member

You can use node.content += on the text node or insert a new text node if there isn't one. Element nodes don't have text content by definition. If that still doesn't make sense, can you please send an example of what you're trying to do.

@benlangfeld
Copy link
Contributor Author

Apologies, I was being unintentionally obtuse. I am infact now appending a
text node, but it would still be nice if the C and Java implementations
behaved consistently.

Regards,
Ben Langfeld

Em 19 Nov 2012, às 21:08, John Shahid [email protected] escreveu:

You can use node.content += on the text node or insert a new text node if
non exist. Element nodes don't have text content by definition. If that
still doesn't make sense, can you please send an example of what you're
trying to do.


Reply to this email directly or view it on
GitHubhttps://github.com//pull/794#issuecomment-10535514.

@jvshahid
Copy link
Member

No worries. I agree that the behavior should be consistent. I'll merge the changes in 311be4b on master but I won't merge the other test.

I'll work on the fix some time later today.

@jvshahid
Copy link
Member

Sorry it took too long to push a fix. I had to wrap my head around the current implementation. I pushed another pull request with the first test and its fix. I'd like @yokolet to review the changes before it gets merged into master.

I'm going to close the issue, but feel free to comment on the new pull request if the problem isn't solved.

@jvshahid jvshahid closed this Nov 20, 2012
@benlangfeld
Copy link
Contributor Author

Thanks John. It was faster than I could have done it, being a Java
n00b/hater and unfamiliar with the internals. Much appreciated.

yokolet added a commit that referenced this pull request Nov 23, 2012
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