-
-
Notifications
You must be signed in to change notification settings - Fork 905
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
parsing numeric character references needs an update of nekohtml
the new version of nekohtml brought a few regressions. this commit fixes but two error warning ones. it avoids to autocomplete the tbody tag around tr tags of a table. the check of unknown html did change upstream and got adjusted. fixes #1113 Sponsored by Lookout Inc.
- Loading branch information
Showing
7 changed files
with
47 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,7 @@ | |
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import org.cyberneko.html.HTMLElements; | ||
import org.jruby.Ruby; | ||
import org.jruby.RubyArray; | ||
import org.jruby.RubyClass; | ||
|
@@ -53,6 +54,24 @@ | |
* @author Yoko Harada <[email protected]> | ||
*/ | ||
public class NokogiriService implements BasicLibraryService { | ||
|
||
// nekohtml from version 1.9.13 they autocomplete tbody around | ||
// tr tags of a table - http://sourceforge.net/p/nekohtml/code/241/ | ||
// this monkey patch undoes this autocompletion | ||
static class MonkeyPatchHTMLElements extends HTMLElements { | ||
static void patchIt() { | ||
Element[] array = ELEMENTS_ARRAY['T'-'A']; | ||
for(int i = 0; i < array.length; i++) { | ||
if (array[i].name.equals("TR")) { | ||
array[i] = new Element(TR, "TR", Element.BLOCK, TABLE, new short[]{TD,TH,TR,COLGROUP,DIV}); | ||
} | ||
} | ||
} | ||
} | ||
static { | ||
MonkeyPatchHTMLElements.patchIt(); | ||
} | ||
|
||
public static final String nokogiriClassCacheGvarName = "$NOKOGIRI_CLASS_CACHE"; | ||
|
||
public boolean basicLoad(Ruby ruby) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters