Skip to content

JSPWIKI-1206 JSPWIKI-1221 Migrate from NekoHTML to htmlunit-neko - #548

Open
arturobernalg wants to merge 4 commits into
apache:masterfrom
arturobernalg:feature/JSPWIKI-1206
Open

arturobernalg wants to merge 4 commits into
apache:masterfrom
arturobernalg:feature/JSPWIKI-1206

Conversation

@arturobernalg

Copy link
Copy Markdown
Member

org.codelibs:nekohtml is no longer maintained. This moves to org.htmlunit:neko-htmlunit 5.6.0, which needs Java 17 like the rest of the project. It is only used by jspwiki-wysiwyg, to turn the HTML of the WYSIWYG editor into XHTML; jspwiki-main declared the dependency without using it, so it is dropped there. The line in LICENSE is updated.

Changes in HtmlStringToWikiTranslator:

  • The new parser does not recognise the SAX validation feature that JDOM's XMLReaderSAX2Factory sets, so JDOM is given its own reader factory.
    • The new parser reports a null namespace URI for attributes, where SAX says it is the empty string, and JDOM rejects it. The parser is wrapped in a small filter that turns those URIs into empty strings.
    • Element names are now lower case, as in XHTML, instead of upper case. The translator already compared names in lower case almost everywhere; the six hard coded upper case names (in XHtmlElementToWikiTranslator and FormDecorator) are lower case now.
      Tests: no test changes. The 18 tests of HtmlStringToWikiTranslatorTest pass, as before, and so do the suites of jspwiki-util, jspwiki-event, jspwiki-main and jspwiki-markdown. Names with a namespace prefix, such as the o:p of pasted Word content, fail in JDOM both before and after this change. I did not build the WAR.

@rbri

rbri commented Oct 26, 2026

Copy link
Copy Markdown

@arturobernalg fyi currently working on 5.7.0; this will include some limits (https://github.com/HtmlUnit/htmlunit-neko#upgrade-notes-within-5x) to avoid dos attacks.

If you like you can test with the latest snapshot - the release is planned for the next weekend...

org.codelibs:nekohtml is no longer maintained. Use org.htmlunit:neko-htmlunit,
which needs Java 17 like the rest of the project.

The new parser does not recognise the SAX validation feature that JDOM's
XMLReaderSAX2Factory sets, and reports a null namespace URI for the attributes,
which JDOM rejects. HtmlStringToWikiTranslator now gives JDOM its own reader
factory, wrapping the parser in a filter that turns those URIs into empty
strings. Element names are now lower case, as in XHTML, so the few hard coded
upper case names in the translator are lower case too.

jspwiki-main declared the dependency without using it, so it is dropped there.
@rbri

rbri commented Nov 3, 2026

Copy link
Copy Markdown

htmlunit-neko 5.7.0 is released

5.7.0 limits the input the parser accepts, which guards against denial of
service with crafted HTML, and drops the first line break after <pre>, as
the HTML specification says. The tests of <pre> expect one line break less.
@arturobernalg

Copy link
Copy Markdown
Member Author

Updated to htmlunit-neko 5.7.0. The only change in behaviour is that the first line break after <pre> is dropped, so the three <pre> assertions in the wysiwyg and markdown tests expect one line break less. Tests of jspwiki-wysiwyg, jspwiki-markdown and jspwiki-main pass, and I checked the WYSIWYG-to-wiki endpoint on a running WAR.

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