nokogiri 1.6.8.rc1-java → 1.6.8.rc2-java
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of nokogiri might be problematic. Click here for more details.
- checksums.yaml +4 -4
 - data/.cross_rubies +2 -0
 - data/CHANGELOG.rdoc +16 -2
 - data/Gemfile +2 -2
 - data/LICENSE.txt +1 -1
 - data/Manifest.txt +0 -1
 - data/Rakefile +5 -3
 - data/ext/java/nokogiri/HtmlElementDescription.java +5 -2
 - data/ext/java/nokogiri/NokogiriService.java +19 -0
 - data/ext/java/nokogiri/XmlNode.java +7 -0
 - data/ext/java/nokogiri/internals/HtmlDomParserContext.java +8 -1
 - data/ext/java/nokogiri/internals/NokogiriErrorHandler.java +1 -2
 - data/ext/java/nokogiri/internals/NokogiriNonStrictErrorHandler4NekoHtml.java +1 -1
 - data/ext/java/nokogiri/internals/NokogiriStrictErrorHandler.java +0 -1
 - data/ext/java/nokogiri/internals/ParserContext.java +4 -0
 - data/ext/java/nokogiri/internals/SaveContextVisitor.java +13 -12
 - data/ext/nokogiri/extconf.rb +1 -2
 - data/ext/nokogiri/html_document.c +6 -6
 - data/ext/nokogiri/html_element_description.c +1 -1
 - data/ext/nokogiri/html_entity_lookup.c +1 -1
 - data/ext/nokogiri/html_sax_parser_context.c +4 -4
 - data/ext/nokogiri/html_sax_push_parser.c +2 -2
 - data/ext/nokogiri/xml_attr.c +2 -2
 - data/ext/nokogiri/xml_comment.c +1 -1
 - data/ext/nokogiri/xml_document.c +18 -18
 - data/ext/nokogiri/xml_encoding_handler.c +3 -3
 - data/ext/nokogiri/xml_entity_reference.c +1 -1
 - data/ext/nokogiri/xml_node.c +27 -27
 - data/ext/nokogiri/xml_node_set.c +3 -11
 - data/ext/nokogiri/xml_processing_instruction.c +2 -2
 - data/ext/nokogiri/xml_reader.c +6 -6
 - data/ext/nokogiri/xml_sax_parser_context.c +1 -1
 - data/ext/nokogiri/xml_sax_push_parser.c +1 -1
 - data/ext/nokogiri/xml_schema.c +1 -1
 - data/ext/nokogiri/xml_text.c +1 -1
 - data/ext/nokogiri/xml_xpath_context.c +6 -6
 - data/ext/nokogiri/xslt_stylesheet.c +6 -6
 - data/lib/nekohtml.jar +0 -0
 - data/lib/nokogiri/nokogiri.jar +0 -0
 - data/lib/nokogiri/version.rb +1 -1
 - data/lib/nokogiri/xml/node.rb +5 -9
 - data/lib/nokogiri/xml/node_set.rb +3 -3
 - data/test/html/test_document.rb +3 -3
 - data/test/html/test_document_encoding.rb +4 -4
 - data/test/html/test_node_encoding.rb +60 -0
 - data/test/test_css_cache.rb +1 -1
 - data/test/test_reader.rb +19 -19
 - data/test/xml/sax/test_parser.rb +3 -7
 - data/test/xml/test_document_encoding.rb +3 -3
 - data/test/xml/test_namespace.rb +2 -2
 - data/test/xml/test_node.rb +4 -4
 - data/test/xml/test_node_encoding.rb +33 -69
 - data/test/xml/test_node_set.rb +1 -1
 - data/test/xml/test_unparented_node.rb +1 -1
 - data/test_all +15 -9
 - metadata +4 -6
 - data/CHANGELOG.ja.rdoc +0 -1075
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 222c1d18ae131bb61d0bddda23df52faacaa128b
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: af7331524ffa5d288b547366a9859a6b2441937f
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 42b48a069c53ae94adad96690691d1dff1440e00ba476ac293778069f0140f871bbf28283ecfef1051d3eaa01a009bab46ea8e181b26500128a27abdec84d95a
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 96cb5071f838df0779bc3d8973a798c81eb689e5b067008c15dfd31d6cdfbd099a91091bca692610d62348932421d32320827112145bf6a8e1d02dae1216047c
         
     | 
    
        data/.cross_rubies
    CHANGED
    
    
    
        data/CHANGELOG.rdoc
    CHANGED
    
    | 
         @@ -5,15 +5,29 @@ 
     | 
|
| 
       5 
5 
     | 
    
         
             
            * (MRI) Bundled Libxml2 is upgraded to 2.9.3, which fixes a series of security issues. See https://mail.gnome.org/archives/xml/2015-November/msg00012.html
         
     | 
| 
       6 
6 
     | 
    
         | 
| 
       7 
7 
     | 
    
         | 
| 
      
 8 
     | 
    
         
            +
            ==== Features
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
            Several changes were made to improve performance:
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
            * [MRI] Simplify NodeSet#to_a with a minor speed-up. (#1397)
         
     | 
| 
      
 13 
     | 
    
         
            +
            * XML::Node#ancestors optimization (#1297) (Thanks, Bruno Sutic!)
         
     | 
| 
      
 14 
     | 
    
         
            +
            * Use Symbol#to_proc where we weren't previously, because Ruby 1.8.7 reasons. (#1296) (Thanks, Bruno Sutic!)
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
       8 
17 
     | 
    
         
             
            ==== Bug Fixes
         
     | 
| 
       9 
18 
     | 
    
         | 
| 
       10 
19 
     | 
    
         
             
            * [JRuby] fix load errors when deploying to JRuby/Torquebox (#1114) (Thanks, @atambo!)
         
     | 
| 
       11 
20 
     | 
    
         
             
            * [JRuby] fix NPE when inspecting nodes returned by NodeSet#drop (#1042) (Thanks, @mkristian!)
         
     | 
| 
       12 
21 
     | 
    
         
             
            * [JRuby] fix nil attriubte node's namespace in reader (#1327) (Thanks, @codekitchen!)
         
     | 
| 
      
 22 
     | 
    
         
            +
            * [JRuby] fix Nokogiri munging unicode characters that require more than 2 bytes (#1113) (Thanks, @mkristian!)
         
     | 
| 
       13 
23 
     | 
    
         
             
            * [MRI] fix assertion failure while accessing attribute node's namespace in reader (#843) (Thanks, @2potatocakes!)
         
     | 
| 
       14 
24 
     | 
    
         
             
            * [MRI] fix issue with GCing namespace nodes returned in an xpath query. (#1155)
         
     | 
| 
      
 25 
     | 
    
         
            +
            * [MRI] Ensure C strings are null-terminated. (#1381)
         
     | 
| 
       15 
26 
     | 
    
         
             
            * unescape special characters in CSS queries (#1303) (Thanks, @twalpole!)
         
     | 
| 
       16 
27 
     | 
    
         
             
            * consistently handle empty documents (#1349)
         
     | 
| 
      
 28 
     | 
    
         
            +
            * Update to mini_portile2 2.1.0 to address whitespace-handling during patching. (#1402)
         
     | 
| 
      
 29 
     | 
    
         
            +
            * Fix encoding of xml node namespaces.
         
     | 
| 
      
 30 
     | 
    
         
            +
            * Work around issue installing Nokogiri on overlayfs (commonly used in Docker containers). (#1370, #1405)
         
     | 
| 
       17 
31 
     | 
    
         | 
| 
       18 
32 
     | 
    
         | 
| 
       19 
33 
     | 
    
         
             
            === 1.6.7.1 / 2015-12-16
         
     | 
| 
         @@ -59,7 +73,7 @@ See #1374 and #1376 for details. 
     | 
|
| 
       59 
73 
     | 
    
         
             
            * [JRuby] reset the namespace cache when replacing the document's innerHtml (#1265) (Thanks, @mkristian!)
         
     | 
| 
       60 
74 
     | 
    
         
             
            * [JRuby] Document#parse should support IO objects that respond to #read. (#1124) (Thanks, Jake Byman!)
         
     | 
| 
       61 
75 
     | 
    
         
             
            * [MRI] Duplicate-id errors when setting the `id` attribute on HTML documents are now silenced. (#1262)
         
     | 
| 
       62 
     | 
    
         
            -
            * [JRuby] SAX parser cuts texts in  
     | 
| 
      
 76 
     | 
    
         
            +
            * [JRuby] SAX parser cuts texts in pieces when square brackets exist. (#1261)
         
     | 
| 
       63 
77 
     | 
    
         
             
            * [JRuby] Namespaced attributes aren't removed by remove_attribute. (#1299)
         
     | 
| 
       64 
78 
     | 
    
         | 
| 
       65 
79 
     | 
    
         | 
| 
         @@ -69,7 +83,7 @@ This version pulls in an upstream patch to the vendored libxml2 to address: 
     | 
|
| 
       69 
83 
     | 
    
         | 
| 
       70 
84 
     | 
    
         
             
            * unclosed comment uninitialized access issue (#1376)
         
     | 
| 
       71 
85 
     | 
    
         | 
| 
       72 
     | 
    
         
            -
            This issue  
     | 
| 
      
 86 
     | 
    
         
            +
            This issue was assigned CVE-2015-8710 after the fact. See http://seclists.org/oss-sec/2015/q4/616 for details.
         
     | 
| 
       73 
87 
     | 
    
         | 
| 
       74 
88 
     | 
    
         | 
| 
       75 
89 
     | 
    
         
             
            === 1.6.6.3 / 2015-11-16
         
     | 
    
        data/Gemfile
    CHANGED
    
    | 
         @@ -4,7 +4,7 @@ 
     | 
|
| 
       4 
4 
     | 
    
         | 
| 
       5 
5 
     | 
    
         
             
            source "https://rubygems.org/"
         
     | 
| 
       6 
6 
     | 
    
         | 
| 
       7 
     | 
    
         
            -
            gem "mini_portile2", "~>2. 
     | 
| 
      
 7 
     | 
    
         
            +
            gem "mini_portile2", "~>2.1.0"
         
     | 
| 
       8 
8 
     | 
    
         | 
| 
       9 
9 
     | 
    
         
             
            gem "rdoc", "~>4.0", :group => [:development, :test]
         
     | 
| 
       10 
10 
     | 
    
         
             
            gem "hoe-bundler", ">=1.1", :group => [:development, :test]
         
     | 
| 
         @@ -14,7 +14,7 @@ gem "hoe-git", ">=1.4", :group => [:development, :test] 
     | 
|
| 
       14 
14 
     | 
    
         
             
            gem "minitest", "~>2.2.2", :group => [:development, :test]
         
     | 
| 
       15 
15 
     | 
    
         
             
            gem "rake", ">=0.9", :group => [:development, :test]
         
     | 
| 
       16 
16 
     | 
    
         
             
            gem "rake-compiler", "~>0.9.2", :group => [:development, :test]
         
     | 
| 
       17 
     | 
    
         
            -
            gem "rake-compiler-dock", "~>0. 
     | 
| 
      
 17 
     | 
    
         
            +
            gem "rake-compiler-dock", "~>0.5.0", :group => [:development, :test]
         
     | 
| 
       18 
18 
     | 
    
         
             
            gem "racc", ">=1.4.6", :group => [:development, :test], :platform => :ruby
         
     | 
| 
       19 
19 
     | 
    
         
             
            gem "rexical", ">=1.0.5", :group => [:development, :test], :platform => :ruby
         
     | 
| 
       20 
20 
     | 
    
         
             
            gem "hoe", "~>3.14", :group => [:development, :test]
         
     | 
    
        data/LICENSE.txt
    CHANGED
    
    
    
        data/Manifest.txt
    CHANGED
    
    
    
        data/Rakefile
    CHANGED
    
    | 
         @@ -129,7 +129,7 @@ HOE = Hoe.spec 'nokogiri' do 
     | 
|
| 
       129 
129 
     | 
    
         
             
              unless java?
         
     | 
| 
       130 
130 
     | 
    
         
             
                self.extra_deps += [
         
     | 
| 
       131 
131 
     | 
    
         
             
                  # Keep this version in sync with the one in extconf.rb !
         
     | 
| 
       132 
     | 
    
         
            -
                  ["mini_portile2",    "~> 2. 
     | 
| 
      
 132 
     | 
    
         
            +
                  ["mini_portile2",    "~> 2.1.0"],
         
     | 
| 
       133 
133 
     | 
    
         
             
                ]
         
     | 
| 
       134 
134 
     | 
    
         
             
              end
         
     | 
| 
       135 
135 
     | 
    
         | 
| 
         @@ -141,7 +141,7 @@ HOE = Hoe.spec 'nokogiri' do 
     | 
|
| 
       141 
141 
     | 
    
         
             
                ["minitest",        "~> 2.2.2"],
         
     | 
| 
       142 
142 
     | 
    
         
             
                ["rake",            ">= 0.9"],
         
     | 
| 
       143 
143 
     | 
    
         
             
                ["rake-compiler",   "~> 0.9.2"],
         
     | 
| 
       144 
     | 
    
         
            -
                ["rake-compiler-dock", "~> 0. 
     | 
| 
      
 144 
     | 
    
         
            +
                ["rake-compiler-dock", "~> 0.5.0"],
         
     | 
| 
       145 
145 
     | 
    
         
             
                ["racc",            ">= 1.4.6"],
         
     | 
| 
       146 
146 
     | 
    
         
             
                ["rexical",         ">= 1.0.5"]
         
     | 
| 
       147 
147 
     | 
    
         
             
              ]
         
     | 
| 
         @@ -184,6 +184,7 @@ if java? 
     | 
|
| 
       184 
184 
     | 
    
         
             
                ext.target_version = '1.6'
         
     | 
| 
       185 
185 
     | 
    
         
             
                jars = ["#{jruby_home}/lib/jruby.jar"] + FileList['lib/*.jar']
         
     | 
| 
       186 
186 
     | 
    
         
             
                ext.classpath = jars.map { |x| File.expand_path x }.join ':'
         
     | 
| 
      
 187 
     | 
    
         
            +
                ext.debug = true if ENV['JAVA_DEBUG']
         
     | 
| 
       187 
188 
     | 
    
         
             
              end
         
     | 
| 
       188 
189 
     | 
    
         | 
| 
       189 
190 
     | 
    
         
             
              task gem_build_path => [:compile] do
         
     | 
| 
         @@ -295,7 +296,8 @@ end 
     | 
|
| 
       295 
296 
     | 
    
         
             
            require 'tasks/test'
         
     | 
| 
       296 
297 
     | 
    
         | 
| 
       297 
298 
     | 
    
         
             
            task :java_debug do
         
     | 
| 
       298 
     | 
    
         
            -
              ENV[' 
     | 
| 
      
 299 
     | 
    
         
            +
              ENV['JRUBY_OPTS'] = "#{ENV['JRUBY_OPTS']} --debug --dev"
         
     | 
| 
      
 300 
     | 
    
         
            +
              ENV['JAVA_OPTS'] = '-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y' if ENV['JAVA_DEBUG']
         
     | 
| 
       299 
301 
     | 
    
         
             
            end
         
     | 
| 
       300 
302 
     | 
    
         | 
| 
       301 
303 
     | 
    
         
             
            if java?
         
     | 
| 
         @@ -105,9 +105,12 @@ public class HtmlElementDescription extends RubyObject { 
     | 
|
| 
       105 
105 
     | 
    
         
             
                public static IRubyObject get(ThreadContext context,
         
     | 
| 
       106 
106 
     | 
    
         
             
                                              IRubyObject klazz, IRubyObject name) {
         
     | 
| 
       107 
107 
     | 
    
         | 
| 
       108 
     | 
    
         
            -
                     
     | 
| 
      
 108 
     | 
    
         
            +
                    // nekohtml will return an element even for invalid names, see
         
     | 
| 
      
 109 
     | 
    
         
            +
                    // http://sourceforge.net/p/nekohtml/code/HEAD/tree/trunk/src/org/cyberneko/html/HTMLElements.java#l514
         
     | 
| 
      
 110 
     | 
    
         
            +
                    // which breaks `test_fetch_nonexistent'
         
     | 
| 
      
 111 
     | 
    
         
            +
                    HTMLElements.Element elem = HTMLElements.getElement(name.asJavaString(), HTMLElements.NO_SUCH_ELEMENT);
         
     | 
| 
       109 
112 
     | 
    
         
             
                    if (elem == HTMLElements.NO_SUCH_ELEMENT)
         
     | 
| 
       110 
     | 
    
         
            -
                        return context. 
     | 
| 
      
 113 
     | 
    
         
            +
                        return context.nil;
         
     | 
| 
       111 
114 
     | 
    
         | 
| 
       112 
115 
     | 
    
         
             
                    HtmlElementDescription desc =
         
     | 
| 
       113 
116 
     | 
    
         
             
                        new HtmlElementDescription(context.getRuntime(), (RubyClass)klazz);
         
     | 
| 
         @@ -36,6 +36,7 @@ import java.util.Collections; 
     | 
|
| 
       36 
36 
     | 
    
         
             
            import java.util.HashMap;
         
     | 
| 
       37 
37 
     | 
    
         
             
            import java.util.Map;
         
     | 
| 
       38 
38 
     | 
    
         | 
| 
      
 39 
     | 
    
         
            +
            import org.cyberneko.html.HTMLElements;
         
     | 
| 
       39 
40 
     | 
    
         
             
            import org.jruby.Ruby;
         
     | 
| 
       40 
41 
     | 
    
         
             
            import org.jruby.RubyArray;
         
     | 
| 
       41 
42 
     | 
    
         
             
            import org.jruby.RubyClass;
         
     | 
| 
         @@ -53,6 +54,24 @@ import org.jruby.runtime.load.BasicLibraryService; 
     | 
|
| 
       53 
54 
     | 
    
         
             
             * @author Yoko Harada <yokolet@gmail.com>
         
     | 
| 
       54 
55 
     | 
    
         
             
             */
         
     | 
| 
       55 
56 
     | 
    
         
             
            public class NokogiriService implements BasicLibraryService {
         
     | 
| 
      
 57 
     | 
    
         
            +
             
     | 
| 
      
 58 
     | 
    
         
            +
                // nekohtml from version 1.9.13 they autocomplete tbody around
         
     | 
| 
      
 59 
     | 
    
         
            +
                // tr tags of a table - http://sourceforge.net/p/nekohtml/code/241/
         
     | 
| 
      
 60 
     | 
    
         
            +
                // this monkey patch undoes this autocompletion
         
     | 
| 
      
 61 
     | 
    
         
            +
                static class MonkeyPatchHTMLElements extends HTMLElements {
         
     | 
| 
      
 62 
     | 
    
         
            +
                    static void patchIt() {
         
     | 
| 
      
 63 
     | 
    
         
            +
                        Element[] array = ELEMENTS_ARRAY['T'-'A'];
         
     | 
| 
      
 64 
     | 
    
         
            +
                        for(int i = 0; i < array.length; i++) {
         
     | 
| 
      
 65 
     | 
    
         
            +
                            if (array[i].name.equals("TR")) {
         
     | 
| 
      
 66 
     | 
    
         
            +
                                array[i] = new Element(TR, "TR", Element.BLOCK, TABLE, new short[]{TD,TH,TR,COLGROUP,DIV});
         
     | 
| 
      
 67 
     | 
    
         
            +
                            }
         
     | 
| 
      
 68 
     | 
    
         
            +
                        }
         
     | 
| 
      
 69 
     | 
    
         
            +
                    }
         
     | 
| 
      
 70 
     | 
    
         
            +
                }
         
     | 
| 
      
 71 
     | 
    
         
            +
                static {
         
     | 
| 
      
 72 
     | 
    
         
            +
                    MonkeyPatchHTMLElements.patchIt();
         
     | 
| 
      
 73 
     | 
    
         
            +
                }
         
     | 
| 
      
 74 
     | 
    
         
            +
             
     | 
| 
       56 
75 
     | 
    
         
             
                public static final String nokogiriClassCacheGvarName = "$NOKOGIRI_CLASS_CACHE";
         
     | 
| 
       57 
76 
     | 
    
         | 
| 
       58 
77 
     | 
    
         
             
                public boolean basicLoad(Ruby ruby) {
         
     | 
| 
         @@ -806,6 +806,13 @@ public class XmlNode extends RubyObject { 
     | 
|
| 
       806 
806 
     | 
    
         
             
                    }
         
     | 
| 
       807 
807 
     | 
    
         | 
| 
       808 
808 
     | 
    
         
             
                    ctx.setInputSource(istream);
         
     | 
| 
      
 809 
     | 
    
         
            +
                    // TODO: for some reason, document.getEncoding() can be null or nil (don't know why)
         
     | 
| 
      
 810 
     | 
    
         
            +
                    // run `test_parse_with_unparented_html_text_context_node' few times to see this happen
         
     | 
| 
      
 811 
     | 
    
         
            +
                    if (document instanceof HtmlDocument && !(document.getEncoding() == null || document.getEncoding().isNil())) {
         
     | 
| 
      
 812 
     | 
    
         
            +
                    	HtmlDomParserContext htmlCtx= (HtmlDomParserContext) ctx;
         
     | 
| 
      
 813 
     | 
    
         
            +
                    	htmlCtx.setEncoding(document.getEncoding().asJavaString());
         
     | 
| 
      
 814 
     | 
    
         
            +
                    }
         
     | 
| 
      
 815 
     | 
    
         
            +
                    
         
     | 
| 
       809 
816 
     | 
    
         
             
                    XmlDocument doc = ctx.parse(context, klass, runtime.getNil());
         
     | 
| 
       810 
817 
     | 
    
         | 
| 
       811 
818 
     | 
    
         
             
                    RubyArray documentErrors = getErrorArray(document);
         
     | 
| 
         @@ -65,7 +65,9 @@ import org.w3c.dom.NodeList; 
     | 
|
| 
       65 
65 
     | 
    
         
             
             */
         
     | 
| 
       66 
66 
     | 
    
         
             
            public class HtmlDomParserContext extends XmlDomParserContext {
         
     | 
| 
       67 
67 
     | 
    
         | 
| 
       68 
     | 
    
         
            -
                 
     | 
| 
      
 68 
     | 
    
         
            +
                private String encoding;
         
     | 
| 
      
 69 
     | 
    
         
            +
             
     | 
| 
      
 70 
     | 
    
         
            +
            	public HtmlDomParserContext(Ruby runtime, IRubyObject options) {
         
     | 
| 
       69 
71 
     | 
    
         
             
                    super(runtime, options);
         
     | 
| 
       70 
72 
     | 
    
         
             
                }
         
     | 
| 
       71 
73 
     | 
    
         | 
| 
         @@ -102,6 +104,11 @@ public class HtmlDomParserContext extends XmlDomParserContext { 
     | 
|
| 
       102 
104 
     | 
    
         
             
                    setFeature("http://cyberneko.org/html/features/report-errors", true);
         
     | 
| 
       103 
105 
     | 
    
         
             
                    setFeature("http://xml.org/sax/features/namespaces", false);
         
     | 
| 
       104 
106 
     | 
    
         
             
                }
         
     | 
| 
      
 107 
     | 
    
         
            +
                
         
     | 
| 
      
 108 
     | 
    
         
            +
                @Override
         
     | 
| 
      
 109 
     | 
    
         
            +
                public void setEncoding(String encoding) {
         
     | 
| 
      
 110 
     | 
    
         
            +
            		super.setEncoding(encoding);
         
     | 
| 
      
 111 
     | 
    
         
            +
                }
         
     | 
| 
       105 
112 
     | 
    
         | 
| 
       106 
113 
     | 
    
         
             
                /**
         
     | 
| 
       107 
114 
     | 
    
         
             
                 * Enable NekoHTML feature for balancing tags in a document fragment.
         
     | 
| 
         @@ -80,7 +80,6 @@ public abstract class NokogiriErrorHandler implements ErrorHandler, XMLErrorHand 
     | 
|
| 
       80 
80 
     | 
    
         
             
                }
         
     | 
| 
       81 
81 
     | 
    
         | 
| 
       82 
82 
     | 
    
         
             
                protected boolean usesNekoHtml(String domain) {
         
     | 
| 
       83 
     | 
    
         
            -
                     
     | 
| 
       84 
     | 
    
         
            -
                    else return false;
         
     | 
| 
      
 83 
     | 
    
         
            +
                    return "http://cyberneko.org/html".equals(domain);
         
     | 
| 
       85 
84 
     | 
    
         
             
                }
         
     | 
| 
       86 
85 
     | 
    
         
             
            }
         
     | 
| 
         @@ -115,7 +115,7 @@ public class NokogiriNonStrictErrorHandler4NekoHtml extends NokogiriErrorHandler 
     | 
|
| 
       115 
115 
     | 
    
         
             
                 * @param e Exception.
         
     | 
| 
       116 
116 
     | 
    
         
             
                 */
         
     | 
| 
       117 
117 
     | 
    
         
             
                public void warning(String domain, String key, XMLParseException e) {
         
     | 
| 
       118 
     | 
    
         
            -
                     
     | 
| 
      
 118 
     | 
    
         
            +
                    errors.add(e);
         
     | 
| 
       119 
119 
     | 
    
         
             
                }
         
     | 
| 
       120 
120 
     | 
    
         | 
| 
       121 
121 
     | 
    
         
             
            }
         
     | 
| 
         @@ -190,6 +190,10 @@ public class ParserContext extends RubyObject { 
     | 
|
| 
       190 
190 
     | 
    
         
             
                    }
         
     | 
| 
       191 
191 
     | 
    
         
             
                    return false;
         
     | 
| 
       192 
192 
     | 
    
         
             
                }
         
     | 
| 
      
 193 
     | 
    
         
            +
                
         
     | 
| 
      
 194 
     | 
    
         
            +
                protected void setEncoding(String encoding) {
         
     | 
| 
      
 195 
     | 
    
         
            +
                	source.setEncoding(encoding);
         
     | 
| 
      
 196 
     | 
    
         
            +
                }
         
     | 
| 
       193 
197 
     | 
    
         | 
| 
       194 
198 
     | 
    
         
             
                /**
         
     | 
| 
       195 
199 
     | 
    
         
             
                 * Set the InputSource to read from <code>file</code>, a String filename.
         
     | 
| 
         @@ -761,24 +761,25 @@ public class SaveContextVisitor { 
     | 
|
| 
       761 
761 
     | 
    
         
             
                    return true;
         
     | 
| 
       762 
762 
     | 
    
         
             
                }
         
     | 
| 
       763 
763 
     | 
    
         | 
| 
       764 
     | 
    
         
            -
                private String getEncoding(Text text) {
         
     | 
| 
       765 
     | 
    
         
            -
                    if (encoding != null) return encoding;
         
     | 
| 
       766 
     | 
    
         
            -
                    encoding = text.getOwnerDocument().getInputEncoding();
         
     | 
| 
       767 
     | 
    
         
            -
                    return encoding;
         
     | 
| 
       768 
     | 
    
         
            -
                }
         
     | 
| 
       769 
     | 
    
         
            -
             
     | 
| 
       770 
764 
     | 
    
         
             
                private String encodeStringToHtmlEntity(String text) {
         
     | 
| 
       771 
765 
     | 
    
         
             
                    if (encoding == null)
         
     | 
| 
       772 
766 
     | 
    
         
             
                      return text;
         
     | 
| 
       773 
767 
     | 
    
         
             
                    CharsetEncoder encoder = Charset.forName(encoding).newEncoder();
         
     | 
| 
       774 
     | 
    
         
            -
                    int last = 126; // = U+007E. No need to encode under U+007E.
         
     | 
| 
       775 
768 
     | 
    
         
             
                    StringBuffer sb = new StringBuffer();
         
     | 
| 
       776 
     | 
    
         
            -
                     
     | 
| 
       777 
     | 
    
         
            -
             
     | 
| 
       778 
     | 
    
         
            -
                         
     | 
| 
       779 
     | 
    
         
            -
                         
     | 
| 
      
 769 
     | 
    
         
            +
                    // make sure we can handle code points that are higher than 2 bytes
         
     | 
| 
      
 770 
     | 
    
         
            +
                    for (int i = 0; i < text.length();) {
         
     | 
| 
      
 771 
     | 
    
         
            +
                        int code = text.codePointAt(i);
         
     | 
| 
      
 772 
     | 
    
         
            +
                        // TODO not sure about bigger offset then 2 ?!
         
     | 
| 
      
 773 
     | 
    
         
            +
                        int offset = code > 65535 ? 2 : 1;
         
     | 
| 
      
 774 
     | 
    
         
            +
                        boolean canEncode = encoder.canEncode(text.substring(i, i + offset));
         
     | 
| 
      
 775 
     | 
    
         
            +
                        if (canEncode) {
         
     | 
| 
      
 776 
     | 
    
         
            +
                            sb.append(text.substring(i, i + offset));
         
     | 
| 
      
 777 
     | 
    
         
            +
                        }
         
     | 
| 
      
 778 
     | 
    
         
            +
                        else {
         
     | 
| 
      
 779 
     | 
    
         
            +
                            sb.append("&#x" + Integer.toHexString(code) + ";");
         
     | 
| 
      
 780 
     | 
    
         
            +
                        }
         
     | 
| 
      
 781 
     | 
    
         
            +
                        i += offset;
         
     | 
| 
       780 
782 
     | 
    
         
             
                    }
         
     | 
| 
       781 
783 
     | 
    
         
             
                    return new String(sb);
         
     | 
| 
       782 
784 
     | 
    
         
             
                }
         
     | 
| 
       783 
     | 
    
         
            -
             
     | 
| 
       784 
785 
     | 
    
         
             
            }
         
     | 
    
        data/ext/nokogiri/extconf.rb
    CHANGED
    
    | 
         @@ -57,7 +57,6 @@ def do_clean 
     | 
|
| 
       57 
57 
     | 
    
         
             
                # clean the ports build directory
         
     | 
| 
       58 
58 
     | 
    
         
             
                Pathname.glob(pwd.join('tmp', '*', 'ports')) { |dir|
         
     | 
| 
       59 
59 
     | 
    
         
             
                  FileUtils.rm_rf(dir, verbose: true)
         
     | 
| 
       60 
     | 
    
         
            -
                  FileUtils.rmdir(dir.parent, parents: true, verbose: true)
         
     | 
| 
       61 
60 
     | 
    
         
             
                }
         
     | 
| 
       62 
61 
     | 
    
         | 
| 
       63 
62 
     | 
    
         
             
                if enable_config('static')
         
     | 
| 
         @@ -393,7 +392,7 @@ else 
     | 
|
| 
       393 
392 
     | 
    
         | 
| 
       394 
393 
     | 
    
         
             
              # The gem version constraint in the Rakefile is not respected at install time.
         
     | 
| 
       395 
394 
     | 
    
         
             
              # Keep this version in sync with the one in the Rakefile !
         
     | 
| 
       396 
     | 
    
         
            -
              gem "mini_portile2", "~> 2. 
     | 
| 
      
 395 
     | 
    
         
            +
              gem "mini_portile2", "~> 2.1.0"
         
     | 
| 
       397 
396 
     | 
    
         
             
              require 'mini_portile2'
         
     | 
| 
       398 
397 
     | 
    
         
             
              message "Using mini_portile version #{MiniPortile::VERSION}\n"
         
     | 
| 
       399 
398 
     | 
    
         | 
| 
         @@ -18,8 +18,8 @@ static VALUE new(int argc, VALUE *argv, VALUE klass) 
     | 
|
| 
       18 
18 
     | 
    
         
             
              external_id = rb_ary_entry(rest, (long)1);
         
     | 
| 
       19 
19 
     | 
    
         | 
| 
       20 
20 
     | 
    
         
             
              doc = htmlNewDoc(
         
     | 
| 
       21 
     | 
    
         
            -
                  RTEST(uri) ? (const xmlChar *) 
     | 
| 
       22 
     | 
    
         
            -
                  RTEST(external_id) ? (const xmlChar *) 
     | 
| 
      
 21 
     | 
    
         
            +
                  RTEST(uri) ? (const xmlChar *)StringValueCStr(uri) : NULL,
         
     | 
| 
      
 22 
     | 
    
         
            +
                  RTEST(external_id) ? (const xmlChar *)StringValueCStr(external_id) : NULL
         
     | 
| 
       23 
23 
     | 
    
         
             
              );
         
     | 
| 
       24 
24 
     | 
    
         
             
              rb_doc = Nokogiri_wrap_xml_document(klass, doc);
         
     | 
| 
       25 
25 
     | 
    
         
             
              rb_obj_call_init(rb_doc, argc, argv);
         
     | 
| 
         @@ -39,8 +39,8 @@ static VALUE read_io( VALUE klass, 
     | 
|
| 
       39 
39 
     | 
    
         
             
                                  VALUE encoding,
         
     | 
| 
       40 
40 
     | 
    
         
             
                                  VALUE options )
         
     | 
| 
       41 
41 
     | 
    
         
             
            {
         
     | 
| 
       42 
     | 
    
         
            -
              const char * c_url    = NIL_P(url)      ? NULL :  
     | 
| 
       43 
     | 
    
         
            -
              const char * c_enc    = NIL_P(encoding) ? NULL :  
     | 
| 
      
 42 
     | 
    
         
            +
              const char * c_url    = NIL_P(url)      ? NULL : StringValueCStr(url);
         
     | 
| 
      
 43 
     | 
    
         
            +
              const char * c_enc    = NIL_P(encoding) ? NULL : StringValueCStr(encoding);
         
     | 
| 
       44 
44 
     | 
    
         
             
              VALUE error_list      = rb_ary_new();
         
     | 
| 
       45 
45 
     | 
    
         
             
              VALUE document;
         
     | 
| 
       46 
46 
     | 
    
         
             
              htmlDocPtr doc;
         
     | 
| 
         @@ -103,8 +103,8 @@ static VALUE read_memory( VALUE klass, 
     | 
|
| 
       103 
103 
     | 
    
         
             
                                      VALUE options )
         
     | 
| 
       104 
104 
     | 
    
         
             
            {
         
     | 
| 
       105 
105 
     | 
    
         
             
              const char * c_buffer = StringValuePtr(string);
         
     | 
| 
       106 
     | 
    
         
            -
              const char * c_url    = NIL_P(url)      ? NULL :  
     | 
| 
       107 
     | 
    
         
            -
              const char * c_enc    = NIL_P(encoding) ? NULL :  
     | 
| 
      
 106 
     | 
    
         
            +
              const char * c_url    = NIL_P(url)      ? NULL : StringValueCStr(url);
         
     | 
| 
      
 107 
     | 
    
         
            +
              const char * c_enc    = NIL_P(encoding) ? NULL : StringValueCStr(encoding);
         
     | 
| 
       108 
108 
     | 
    
         
             
              int len               = (int)RSTRING_LEN(string);
         
     | 
| 
       109 
109 
     | 
    
         
             
              VALUE error_list      = rb_ary_new();
         
     | 
| 
       110 
110 
     | 
    
         
             
              VALUE document;
         
     | 
| 
         @@ -245,7 +245,7 @@ static VALUE name(VALUE self) 
     | 
|
| 
       245 
245 
     | 
    
         
             
            static VALUE get_description(VALUE klass, VALUE tag_name)
         
     | 
| 
       246 
246 
     | 
    
         
             
            {
         
     | 
| 
       247 
247 
     | 
    
         
             
              const htmlElemDesc * description = htmlTagLookup(
         
     | 
| 
       248 
     | 
    
         
            -
                  (const xmlChar *) 
     | 
| 
      
 248 
     | 
    
         
            +
                  (const xmlChar *)StringValueCStr(tag_name)
         
     | 
| 
       249 
249 
     | 
    
         
             
              );
         
     | 
| 
       250 
250 
     | 
    
         | 
| 
       251 
251 
     | 
    
         
             
              if(NULL == description) return Qnil;
         
     | 
| 
         @@ -31,12 +31,12 @@ parse_memory(VALUE klass, VALUE data, VALUE encoding) 
     | 
|
| 
       31 
31 
     | 
    
         
             
                }
         
     | 
| 
       32 
32 
     | 
    
         | 
| 
       33 
33 
     | 
    
         
             
                if (RTEST(encoding)) {
         
     | 
| 
       34 
     | 
    
         
            -
            	xmlCharEncodingHandlerPtr enc = xmlFindCharEncodingHandler( 
     | 
| 
      
 34 
     | 
    
         
            +
            	xmlCharEncodingHandlerPtr enc = xmlFindCharEncodingHandler(StringValueCStr(encoding));
         
     | 
| 
       35 
35 
     | 
    
         
             
            	if (enc != NULL) {
         
     | 
| 
       36 
36 
     | 
    
         
             
            	    xmlSwitchToEncoding(ctxt, enc);
         
     | 
| 
       37 
37 
     | 
    
         
             
            	    if (ctxt->errNo == XML_ERR_UNSUPPORTED_ENCODING) {
         
     | 
| 
       38 
38 
     | 
    
         
             
            		rb_raise(rb_eRuntimeError, "Unsupported encoding %s",
         
     | 
| 
       39 
     | 
    
         
            -
            			  
     | 
| 
      
 39 
     | 
    
         
            +
            			 StringValueCStr(encoding));
         
     | 
| 
       40 
40 
     | 
    
         
             
            	    }
         
     | 
| 
       41 
41 
     | 
    
         
             
            	}
         
     | 
| 
       42 
42 
     | 
    
         
             
                }
         
     | 
| 
         @@ -47,8 +47,8 @@ parse_memory(VALUE klass, VALUE data, VALUE encoding) 
     | 
|
| 
       47 
47 
     | 
    
         
             
            static VALUE parse_file(VALUE klass, VALUE filename, VALUE encoding)
         
     | 
| 
       48 
48 
     | 
    
         
             
            {
         
     | 
| 
       49 
49 
     | 
    
         
             
              htmlParserCtxtPtr ctxt = htmlCreateFileParserCtxt(
         
     | 
| 
       50 
     | 
    
         
            -
                   
     | 
| 
       51 
     | 
    
         
            -
                   
     | 
| 
      
 50 
     | 
    
         
            +
                  StringValueCStr(filename),
         
     | 
| 
      
 51 
     | 
    
         
            +
                  StringValueCStr(encoding)
         
     | 
| 
       52 
52 
     | 
    
         
             
              );
         
     | 
| 
       53 
53 
     | 
    
         
             
              return Data_Wrap_Struct(klass, NULL, deallocate, ctxt);
         
     | 
| 
       54 
54 
     | 
    
         
             
            }
         
     | 
| 
         @@ -46,10 +46,10 @@ static VALUE initialize_native(VALUE self, VALUE _xml_sax, VALUE _filename, 
     | 
|
| 
       46 
46 
     | 
    
         | 
| 
       47 
47 
     | 
    
         
             
              Data_Get_Struct(_xml_sax, xmlSAXHandler, sax);
         
     | 
| 
       48 
48 
     | 
    
         | 
| 
       49 
     | 
    
         
            -
              if(_filename != Qnil) filename =  
     | 
| 
      
 49 
     | 
    
         
            +
              if(_filename != Qnil) filename = StringValueCStr(_filename);
         
     | 
| 
       50 
50 
     | 
    
         | 
| 
       51 
51 
     | 
    
         
             
              if (!NIL_P(encoding)) {
         
     | 
| 
       52 
     | 
    
         
            -
                enc = xmlParseCharEncoding( 
     | 
| 
      
 52 
     | 
    
         
            +
                enc = xmlParseCharEncoding(StringValueCStr(encoding));
         
     | 
| 
       53 
53 
     | 
    
         
             
                if (enc == XML_CHAR_ENCODING_ERROR)
         
     | 
| 
       54 
54 
     | 
    
         
             
                  rb_raise(rb_eArgError, "Unsupported Encoding");
         
     | 
| 
       55 
55 
     | 
    
         
             
              }
         
     | 
    
        data/ext/nokogiri/xml_attr.c
    CHANGED
    
    | 
         @@ -20,7 +20,7 @@ static VALUE set_value(VALUE self, VALUE content) 
     | 
|
| 
       20 
20 
     | 
    
         
             
                xmlNode *tmp;
         
     | 
| 
       21 
21 
     | 
    
         | 
| 
       22 
22 
     | 
    
         
             
                /* Encode our content */
         
     | 
| 
       23 
     | 
    
         
            -
                buffer = xmlEncodeEntitiesReentrant(attr->doc, (unsigned char *) 
     | 
| 
      
 23 
     | 
    
         
            +
                buffer = xmlEncodeEntitiesReentrant(attr->doc, (unsigned char *)StringValueCStr(content));
         
     | 
| 
       24 
24 
     | 
    
         | 
| 
       25 
25 
     | 
    
         
             
                attr->children = xmlStringGetNodeList(attr->doc, buffer);
         
     | 
| 
       26 
26 
     | 
    
         
             
                attr->last = NULL;
         
     | 
| 
         @@ -61,7 +61,7 @@ static VALUE new(int argc, VALUE *argv, VALUE klass) 
     | 
|
| 
       61 
61 
     | 
    
         | 
| 
       62 
62 
     | 
    
         
             
              node = xmlNewDocProp(
         
     | 
| 
       63 
63 
     | 
    
         
             
                  xml_doc,
         
     | 
| 
       64 
     | 
    
         
            -
                  (const xmlChar *) 
     | 
| 
      
 64 
     | 
    
         
            +
                  (const xmlChar *)StringValueCStr(name),
         
     | 
| 
       65 
65 
     | 
    
         
             
                  NULL
         
     | 
| 
       66 
66 
     | 
    
         
             
              );
         
     | 
| 
       67 
67 
     | 
    
         | 
    
        data/ext/nokogiri/xml_comment.c
    CHANGED