jOOQ / jOOX

jOOX - The Power of jQuery Applied to W3C DOM Like JDBC, DOM is a powerful, yet very verbose low-level API to manipulate XML. The HTML DOM an be manipulated with the popular jQuery product, in JavaScript. Why don't we have jQuery in Java? jOOX is jQuery's XML parts, applied to Java.
http://www.jooq.org/products
Apache License 2.0
495 stars 43 forks source link

Creating a Match with ampersand in content causes printing to error out #162

Closed PascalSchumacher closed 5 years ago

PascalSchumacher commented 5 years ago

Expected behavior and actual behavior:

When a Match with an ampersand in content is created a message like [Fatal Error] :1:11: The entity name must immediately follow the '&' in the entity reference. is printed to error out.

Functionally is not affected. The document is created and is well formed.

A simplified test to reproduce the problem:

public void testContentContainsAmpersand() {
    $("company", "a & b");
}

Versions:

PascalSchumacher commented 5 years ago

Looks like this was caused by the changes for https://github.com/jOOQ/jOOX/pull/150 / https://github.com/jOOQ/jOOX/issues/152 in https://github.com/jOOQ/jOOX/blob/master/jOOX/src/main/java/org/joox/Util.java#L103 This change cause a SaxException to be thrown for content containing an ampersand. The exception is swallowed in https://github.com/jOOQ/jOOX/blob/master/jOOX/src/main/java/org/joox/Util.java#L143 but the com.sun.org.apache.xerces.internal.util.DefaultErrorHandler writes to error out.

The error output can be suppressed by setting the error handler of the DocumentBuilder used by jOOX to null, but avoiding the exception somehow would be a better.

Any ideas/hints how to fix this?

Thanks in advance, Pascal

lukaseder commented 5 years ago

Thank you very much for your report. Unfortunately, I cannot reproduce this:

When a Match with an ampersand in content is created a message like [Fatal Error] :1:11: The entity name must immediately follow the '&' in the entity reference. is printed to error out.

Running your test doesn't yield any error messages on my machine. How can this be reproduced?

lukaseder commented 5 years ago

My mistake - I had checked this with version 1.2.0

lukaseder commented 5 years ago

Thanks again for your report. This is fixed for jOOX 1.7.0. Currently, there haven't been enough changes to justify a release.

lukaseder commented 5 years ago

Moving to 1.6.2 as we're getting more reports (e.g. #163), which might make a timely release more probable

lukaseder commented 5 years ago

Version 1.6.2 has been released including a fix for this issue. It will be available from Maven Central shortly.

PascalSchumacher commented 5 years ago

Thanks!

Sadly is not on maven central yet and https://github.com/jOOQ/jOOX/releases also does not display it.

lukaseder commented 5 years ago

Luckily it is! https://search.maven.org/search?q=joox

PascalSchumacher commented 5 years ago

For some reason I was looking for 1.6.3. My mistake.

Sorry and thanks!