htmlparser-1.2.1.diff 2.87 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
diff -r 7a65a61dbdfa src/nu/validator/htmlparser/impl/ElementName.java
--- a/src/nu/validator/htmlparser/impl/ElementName.java	Wed Sep 22 18:01:16 2010 +0300
+++ b/src/nu/validator/htmlparser/impl/ElementName.java	Tue Oct 12 16:36:02 2010 +0200
@@ -1,4 +1,4 @@
-/*
+    /*
  * Copyright (c) 2008-2010 Mozilla Foundation
  *
  * Permission is hereby granted, free of charge, to any person obtaining a 
diff -r 7a65a61dbdfa src/nu/validator/htmlparser/impl/ErrorReportingTokenizer.java
--- a/src/nu/validator/htmlparser/impl/ErrorReportingTokenizer.java	Wed Sep 22 18:01:16 2010 +0300
+++ b/src/nu/validator/htmlparser/impl/ErrorReportingTokenizer.java	Tue Oct 12 16:36:02 2010 +0200
@@ -328,7 +328,8 @@
     @Override protected int transition(int from, int to, boolean reconsume,
             int pos) throws SAXException {
         if (transitionHandler != null) {
-            transitionHandler.transition(from, to, reconsume, pos);
+            //we need to use the real offset in the source, not just the buffer offset...
+            transitionHandler.transition(from, to, reconsume, currentBufferGlobalOffset + pos);
         }
         return to;
     }
diff -r 7a65a61dbdfa src/nu/validator/htmlparser/impl/Tokenizer.java
--- a/src/nu/validator/htmlparser/impl/Tokenizer.java	Wed Sep 22 18:01:16 2010 +0300
+++ b/src/nu/validator/htmlparser/impl/Tokenizer.java	Tue Oct 12 16:36:02 2010 +0200
@@ -507,6 +507,9 @@
 
     // [NOCPP[
 
+    //holds the offset of the current buffer relative to the beginning of the input source
+    protected int currentBufferGlobalOffset;
+
     protected LocatorImpl ampersandLocation;
 
     public Tokenizer(TokenHandler tokenHandler, boolean newAttributesEachTime) {
@@ -1333,6 +1336,11 @@
         } else {
             buffer.setStart(pos + 1);
         }
+
+        if(!buffer.hasMore()) {
+            currentBufferGlobalOffset += buffer.getEnd();
+        }
+
         return lastCR;
     }
 
@@ -6776,6 +6784,7 @@
         }
         // ]NOCPP]
         resetToDataState();
+        currentBufferGlobalOffset = 0;
     }
 
     protected void errGarbageAfterLtSlash() throws SAXException {
diff -r 7a65a61dbdfa src/nu/validator/htmlparser/impl/TreeBuilder.java
--- a/src/nu/validator/htmlparser/impl/TreeBuilder.java	Wed Sep 22 18:01:16 2010 +0300
+++ b/src/nu/validator/htmlparser/impl/TreeBuilder.java	Tue Oct 12 16:36:02 2010 +0200
@@ -1426,7 +1426,7 @@
         end();
     }
 
-    public final void startTag(ElementName elementName,
+    public void startTag(ElementName elementName,
             HtmlAttributes attributes, boolean selfClosing) throws SAXException {
         flushCharacters();
         // [NOCPP[
@@ -3134,7 +3134,7 @@
         }
     }
 
-    public final void endTag(ElementName elementName) throws SAXException {
+    public void endTag(ElementName elementName) throws SAXException {
         flushCharacters();
         needToDropLF = false;
         int eltPos;