nokogiri 1.12.2-java → 1.13.0-java
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of nokogiri might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Gemfile +2 -0
- data/README.md +9 -7
- data/bin/nokogiri +63 -50
- data/dependencies.yml +5 -6
- data/ext/java/nokogiri/Html4SaxPushParser.java +14 -19
- data/ext/java/nokogiri/XmlDocumentFragment.java +4 -15
- data/ext/java/nokogiri/XmlNamespace.java +0 -8
- data/ext/java/nokogiri/XmlNode.java +32 -16
- data/ext/java/nokogiri/XmlNodeSet.java +0 -4
- data/ext/java/nokogiri/XmlReader.java +12 -0
- data/ext/java/nokogiri/XmlSaxParserContext.java +31 -93
- data/ext/java/nokogiri/XmlSaxPushParser.java +17 -25
- data/ext/java/nokogiri/XmlSchema.java +1 -1
- data/ext/java/nokogiri/internals/NokogiriEntityResolver.java +1 -1
- data/ext/java/nokogiri/internals/NokogiriErrorHandler.java +29 -8
- data/ext/java/nokogiri/internals/NokogiriHandler.java +6 -24
- data/ext/java/nokogiri/internals/NokogiriNonStrictErrorHandler.java +9 -8
- data/ext/java/nokogiri/internals/NokogiriNonStrictErrorHandler4NekoHtml.java +10 -9
- data/ext/java/nokogiri/internals/NokogiriStrictErrorHandler.java +7 -6
- data/ext/java/nokogiri/internals/SaveContextVisitor.java +2 -0
- data/ext/java/nokogiri/internals/XmlDomParserContext.java +16 -25
- data/ext/nokogiri/extconf.rb +51 -35
- data/ext/nokogiri/gumbo.c +11 -11
- data/ext/nokogiri/html4_element_description.c +1 -1
- data/ext/nokogiri/html4_sax_parser_context.c +2 -1
- data/ext/nokogiri/nokogiri.c +1 -1
- data/ext/nokogiri/xml_document.c +36 -36
- data/ext/nokogiri/xml_document_fragment.c +0 -2
- data/ext/nokogiri/xml_dtd.c +2 -2
- data/ext/nokogiri/xml_encoding_handler.c +25 -11
- data/ext/nokogiri/xml_namespace.c +2 -2
- data/ext/nokogiri/xml_node.c +647 -335
- data/ext/nokogiri/xml_reader.c +37 -11
- data/ext/nokogiri/xml_xpath_context.c +72 -49
- data/lib/nokogiri/class_resolver.rb +67 -0
- data/lib/nokogiri/css/node.rb +9 -8
- data/lib/nokogiri/css/parser.rb +11 -3
- data/lib/nokogiri/css/parser.y +10 -2
- data/lib/nokogiri/css/parser_extras.rb +20 -20
- data/lib/nokogiri/css/syntax_error.rb +1 -0
- data/lib/nokogiri/css/tokenizer.rb +2 -1
- data/lib/nokogiri/css/tokenizer.rex +2 -1
- data/lib/nokogiri/css/xpath_visitor.rb +174 -75
- data/lib/nokogiri/css.rb +38 -6
- data/lib/nokogiri/decorators/slop.rb +8 -7
- data/lib/nokogiri/extension.rb +1 -1
- data/lib/nokogiri/gumbo.rb +1 -0
- data/lib/nokogiri/html.rb +16 -10
- data/lib/nokogiri/html4/builder.rb +1 -0
- data/lib/nokogiri/html4/document.rb +84 -75
- data/lib/nokogiri/html4/document_fragment.rb +11 -7
- data/lib/nokogiri/html4/element_description.rb +1 -0
- data/lib/nokogiri/html4/element_description_defaults.rb +426 -520
- data/lib/nokogiri/html4/entity_lookup.rb +2 -1
- data/lib/nokogiri/html4/sax/parser.rb +2 -1
- data/lib/nokogiri/html4/sax/parser_context.rb +1 -0
- data/lib/nokogiri/html4/sax/push_parser.rb +7 -7
- data/lib/nokogiri/html4.rb +11 -5
- data/lib/nokogiri/html5/document.rb +24 -10
- data/lib/nokogiri/html5/document_fragment.rb +5 -2
- data/lib/nokogiri/html5/node.rb +6 -3
- data/lib/nokogiri/html5.rb +68 -64
- data/lib/nokogiri/jruby/dependencies.rb +10 -9
- data/lib/nokogiri/nokogiri.jar +0 -0
- data/lib/nokogiri/syntax_error.rb +1 -0
- data/lib/nokogiri/version/constant.rb +2 -1
- data/lib/nokogiri/version/info.rb +19 -13
- data/lib/nokogiri/version.rb +1 -0
- data/lib/nokogiri/xml/attr.rb +5 -3
- data/lib/nokogiri/xml/attribute_decl.rb +2 -1
- data/lib/nokogiri/xml/builder.rb +69 -31
- data/lib/nokogiri/xml/cdata.rb +2 -1
- data/lib/nokogiri/xml/character_data.rb +1 -0
- data/lib/nokogiri/xml/document.rb +178 -96
- data/lib/nokogiri/xml/document_fragment.rb +41 -38
- data/lib/nokogiri/xml/dtd.rb +3 -2
- data/lib/nokogiri/xml/element_content.rb +1 -0
- data/lib/nokogiri/xml/element_decl.rb +2 -1
- data/lib/nokogiri/xml/entity_decl.rb +3 -2
- data/lib/nokogiri/xml/entity_reference.rb +1 -0
- data/lib/nokogiri/xml/namespace.rb +2 -0
- data/lib/nokogiri/xml/node/save_options.rb +7 -4
- data/lib/nokogiri/xml/node.rb +512 -348
- data/lib/nokogiri/xml/node_set.rb +46 -54
- data/lib/nokogiri/xml/notation.rb +12 -0
- data/lib/nokogiri/xml/parse_options.rb +11 -7
- data/lib/nokogiri/xml/pp/character_data.rb +8 -6
- data/lib/nokogiri/xml/pp/node.rb +24 -26
- data/lib/nokogiri/xml/pp.rb +1 -0
- data/lib/nokogiri/xml/processing_instruction.rb +2 -1
- data/lib/nokogiri/xml/reader.rb +17 -19
- data/lib/nokogiri/xml/relax_ng.rb +1 -0
- data/lib/nokogiri/xml/sax/document.rb +20 -19
- data/lib/nokogiri/xml/sax/parser.rb +36 -34
- data/lib/nokogiri/xml/sax/parser_context.rb +7 -3
- data/lib/nokogiri/xml/sax/push_parser.rb +5 -5
- data/lib/nokogiri/xml/sax.rb +1 -0
- data/lib/nokogiri/xml/schema.rb +7 -6
- data/lib/nokogiri/xml/searchable.rb +42 -22
- data/lib/nokogiri/xml/syntax_error.rb +4 -4
- data/lib/nokogiri/xml/text.rb +1 -0
- data/lib/nokogiri/xml/xpath/syntax_error.rb +2 -1
- data/lib/nokogiri/xml/xpath.rb +12 -0
- data/lib/nokogiri/xml/xpath_context.rb +2 -3
- data/lib/nokogiri/xml.rb +3 -3
- data/lib/nokogiri/xslt/stylesheet.rb +1 -0
- data/lib/nokogiri/xslt.rb +3 -2
- data/lib/nokogiri.rb +19 -16
- data/lib/xsd/xmlparser/nokogiri.rb +25 -24
- metadata +102 -30
@@ -1,30 +1,24 @@
|
|
1
1
|
package nokogiri.internals;
|
2
2
|
|
3
|
-
import
|
4
|
-
import
|
5
|
-
|
6
|
-
import java.io.IOException;
|
7
|
-
import java.util.ArrayList;
|
8
|
-
import java.util.List;
|
9
|
-
|
3
|
+
import nokogiri.XmlDocument;
|
4
|
+
import nokogiri.XmlDtd;
|
5
|
+
import nokogiri.XmlSyntaxError;
|
10
6
|
import org.apache.xerces.parsers.DOMParser;
|
11
|
-
import org.jruby
|
12
|
-
import org.jruby.RubyArray;
|
13
|
-
import org.jruby.RubyClass;
|
14
|
-
import org.jruby.RubyFixnum;
|
7
|
+
import org.jruby.*;
|
15
8
|
import org.jruby.exceptions.RaiseException;
|
16
|
-
import org.jruby.runtime.ThreadContext;
|
17
9
|
import org.jruby.runtime.Helpers;
|
10
|
+
import org.jruby.runtime.ThreadContext;
|
18
11
|
import org.jruby.runtime.builtin.IRubyObject;
|
19
12
|
import org.w3c.dom.Document;
|
20
13
|
import org.w3c.dom.Node;
|
21
14
|
import org.w3c.dom.NodeList;
|
22
15
|
import org.xml.sax.SAXException;
|
23
16
|
|
24
|
-
import
|
25
|
-
import
|
26
|
-
import
|
27
|
-
|
17
|
+
import java.io.IOException;
|
18
|
+
import java.util.ArrayList;
|
19
|
+
import java.util.List;
|
20
|
+
|
21
|
+
import static nokogiri.internals.NokogiriHelpers.isBlank;
|
28
22
|
|
29
23
|
/**
|
30
24
|
* Parser class for XML DOM processing. This class actually parses XML document
|
@@ -48,7 +42,6 @@ public class XmlDomParserContext extends ParserContext
|
|
48
42
|
protected static final String FEATURE_NOT_EXPAND_ENTITY =
|
49
43
|
"http://apache.org/xml/features/dom/create-entity-ref-nodes";
|
50
44
|
protected static final String FEATURE_VALIDATION = "http://xml.org/sax/features/validation";
|
51
|
-
private static final String XINCLUDE_FEATURE_ID = "http://apache.org/xml/features/xinclude";
|
52
45
|
private static final String SECURITY_MANAGER = "http://apache.org/xml/properties/security-manager";
|
53
46
|
|
54
47
|
protected ParserContext.Options options;
|
@@ -69,17 +62,17 @@ public class XmlDomParserContext extends ParserContext
|
|
69
62
|
this.options = new ParserContext.Options(RubyFixnum.fix2long(options));
|
70
63
|
java_encoding = NokogiriHelpers.getValidEncodingOrNull(encoding);
|
71
64
|
ruby_encoding = encoding;
|
72
|
-
initErrorHandler();
|
65
|
+
initErrorHandler(runtime);
|
73
66
|
initParser(runtime);
|
74
67
|
}
|
75
68
|
|
76
69
|
protected void
|
77
|
-
initErrorHandler()
|
70
|
+
initErrorHandler(Ruby runtime)
|
78
71
|
{
|
79
72
|
if (options.recover) {
|
80
|
-
errorHandler = new NokogiriNonStrictErrorHandler(options.noError, options.noWarning);
|
73
|
+
errorHandler = new NokogiriNonStrictErrorHandler(runtime, options.noError, options.noWarning);
|
81
74
|
} else {
|
82
|
-
errorHandler = new NokogiriStrictErrorHandler(options.noError, options.noWarning);
|
75
|
+
errorHandler = new NokogiriStrictErrorHandler(runtime, options.noError, options.noWarning);
|
83
76
|
}
|
84
77
|
}
|
85
78
|
|
@@ -161,12 +154,10 @@ public class XmlDomParserContext extends ParserContext
|
|
161
154
|
mapErrors(ThreadContext context, NokogiriErrorHandler errorHandler)
|
162
155
|
{
|
163
156
|
final Ruby runtime = context.runtime;
|
164
|
-
final List<
|
157
|
+
final List<RubyException> errors = errorHandler.getErrors();
|
165
158
|
final IRubyObject[] errorsAry = new IRubyObject[errors.size()];
|
166
159
|
for (int i = 0; i < errors.size(); i++) {
|
167
|
-
|
168
|
-
xmlSyntaxError.setException(errors.get(i));
|
169
|
-
errorsAry[i] = xmlSyntaxError;
|
160
|
+
errorsAry[i] = errors.get(i);
|
170
161
|
}
|
171
162
|
return runtime.newArrayNoCopy(errorsAry);
|
172
163
|
}
|
data/ext/nokogiri/extconf.rb
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
|
2
|
+
|
3
|
+
# rubocop:disable Style/GlobalVars
|
4
|
+
|
5
|
+
ENV["RC_ARCHS"] = "" if RUBY_PLATFORM.include?("darwin")
|
3
6
|
|
4
7
|
require "mkmf"
|
5
8
|
require "rbconfig"
|
@@ -12,16 +15,14 @@ PACKAGE_ROOT_DIR = File.expand_path(File.join(File.dirname(__FILE__), "..", ".."
|
|
12
15
|
REQUIRED_LIBXML_VERSION = "2.6.21"
|
13
16
|
RECOMMENDED_LIBXML_VERSION = "2.9.3"
|
14
17
|
|
15
|
-
#
|
16
|
-
# Keep this version in sync with the one in the Rakefile !
|
17
|
-
REQUIRED_MINI_PORTILE_VERSION = "~> 2.6.1"
|
18
|
+
REQUIRED_MINI_PORTILE_VERSION = "~> 2.7.0" # keep this version in sync with the one in the gemspec
|
18
19
|
REQUIRED_PKG_CONFIG_VERSION = "~> 1.1"
|
19
20
|
|
20
21
|
# Keep track of what versions of what libraries we build against
|
21
22
|
OTHER_LIBRARY_VERSIONS = {}
|
22
23
|
|
23
24
|
NOKOGIRI_HELP_MESSAGE = <<~HELP
|
24
|
-
USAGE: ruby #{$
|
25
|
+
USAGE: ruby #{$PROGRAM_NAME} [options]
|
25
26
|
|
26
27
|
Flags that are always valid:
|
27
28
|
|
@@ -175,23 +176,23 @@ def config_system_libraries?
|
|
175
176
|
end
|
176
177
|
|
177
178
|
def windows?
|
178
|
-
RbConfig::CONFIG["target_os"]
|
179
|
+
RbConfig::CONFIG["target_os"].match?(/mingw|mswin/)
|
179
180
|
end
|
180
181
|
|
181
182
|
def solaris?
|
182
|
-
RbConfig::CONFIG["target_os"]
|
183
|
+
RbConfig::CONFIG["target_os"].include?("solaris")
|
183
184
|
end
|
184
185
|
|
185
186
|
def darwin?
|
186
|
-
RbConfig::CONFIG["target_os"]
|
187
|
+
RbConfig::CONFIG["target_os"].include?("darwin")
|
187
188
|
end
|
188
189
|
|
189
190
|
def openbsd?
|
190
|
-
RbConfig::CONFIG["target_os"]
|
191
|
+
RbConfig::CONFIG["target_os"].include?("openbsd")
|
191
192
|
end
|
192
193
|
|
193
194
|
def aix?
|
194
|
-
RbConfig::CONFIG["target_os"]
|
195
|
+
RbConfig::CONFIG["target_os"].include?("aix")
|
195
196
|
end
|
196
197
|
|
197
198
|
def nix?
|
@@ -284,17 +285,16 @@ ensure
|
|
284
285
|
end
|
285
286
|
|
286
287
|
def abort_could_not_find_library(lib)
|
287
|
-
|
288
|
+
callers = caller(1..2).join("\n")
|
289
|
+
abort("-----\n#{callers}\n#{lib} is missing. Please locate mkmf.log to investigate how it is failing.\n-----")
|
288
290
|
end
|
289
291
|
|
290
|
-
def chdir_for_build
|
292
|
+
def chdir_for_build(&block)
|
291
293
|
# When using rake-compiler-dock on Windows, the underlying Virtualbox shared
|
292
294
|
# folders don't support symlinks, but libiconv expects it for a build on
|
293
295
|
# Linux. We work around this limitation by using the temp dir for cooking.
|
294
|
-
build_dir = ENV["RCD_HOST_RUBY_PLATFORM"].to_s
|
295
|
-
Dir.chdir(build_dir)
|
296
|
-
yield
|
297
|
-
end
|
296
|
+
build_dir = /mingw|mswin|cygwin/.match?(ENV["RCD_HOST_RUBY_PLATFORM"].to_s) ? "/tmp" : "."
|
297
|
+
Dir.chdir(build_dir, &block)
|
298
298
|
end
|
299
299
|
|
300
300
|
def sh_export_path(path)
|
@@ -402,9 +402,9 @@ def iconv_configure_flags
|
|
402
402
|
abort_could_not_find_library("libiconv")
|
403
403
|
end
|
404
404
|
|
405
|
-
def process_recipe(name, version, static_p, cross_p, cacheable_p=true)
|
405
|
+
def process_recipe(name, version, static_p, cross_p, cacheable_p = true)
|
406
406
|
require "rubygems"
|
407
|
-
gem("mini_portile2", REQUIRED_MINI_PORTILE_VERSION)
|
407
|
+
gem("mini_portile2", REQUIRED_MINI_PORTILE_VERSION) # gemspec is not respected at install time
|
408
408
|
require "mini_portile2"
|
409
409
|
message("Using mini_portile version #{MiniPortile::VERSION}\n")
|
410
410
|
|
@@ -413,9 +413,13 @@ def process_recipe(name, version, static_p, cross_p, cacheable_p=true)
|
|
413
413
|
end
|
414
414
|
|
415
415
|
MiniPortile.new(name, version).tap do |recipe|
|
416
|
+
def recipe.port_path
|
417
|
+
"#{@target}/#{RUBY_PLATFORM}/#{@name}/#{@version}"
|
418
|
+
end
|
419
|
+
|
416
420
|
recipe.target = File.join(PACKAGE_ROOT_DIR, "ports") if cacheable_p
|
417
|
-
# Prefer host_alias over host in order to use
|
418
|
-
#
|
421
|
+
# Prefer host_alias over host in order to use the correct compiler prefix for cross build, but
|
422
|
+
# use host if not set.
|
419
423
|
recipe.host = RbConfig::CONFIG["host_alias"].empty? ? RbConfig::CONFIG["host"] : RbConfig::CONFIG["host_alias"]
|
420
424
|
recipe.configure_options << "--libdir=#{File.join(recipe.path, "lib")}"
|
421
425
|
|
@@ -462,7 +466,7 @@ def process_recipe(name, version, static_p, cross_p, cacheable_p=true)
|
|
462
466
|
end
|
463
467
|
|
464
468
|
if RbConfig::CONFIG["target_cpu"] == "universal"
|
465
|
-
|
469
|
+
["CFLAGS", "LDFLAGS"].each do |key|
|
466
470
|
unless env[key].include?("-arch")
|
467
471
|
env[key] = concat_flags(env[key], RbConfig::CONFIG["ARCH_FLAG"])
|
468
472
|
end
|
@@ -473,7 +477,7 @@ def process_recipe(name, version, static_p, cross_p, cacheable_p=true)
|
|
473
477
|
"#{key}=#{value.strip}"
|
474
478
|
end
|
475
479
|
|
476
|
-
checkpoint = "#{recipe.target}/#{recipe.name}-#{recipe.version}-#{
|
480
|
+
checkpoint = "#{recipe.target}/#{recipe.name}-#{recipe.version}-#{RUBY_PLATFORM}.installed"
|
477
481
|
if File.exist?(checkpoint) && !recipe.source_directory
|
478
482
|
message("Building Nokogiri with a packaged version of #{name}-#{version}.\n")
|
479
483
|
else
|
@@ -487,7 +491,7 @@ def process_recipe(name, version, static_p, cross_p, cacheable_p=true)
|
|
487
491
|
message("The following patches are being applied:\n")
|
488
492
|
|
489
493
|
recipe.patch_files.each do |patch|
|
490
|
-
message(" - %s\n"
|
494
|
+
message(format(" - %s\n", File.basename(patch)))
|
491
495
|
end
|
492
496
|
end
|
493
497
|
|
@@ -594,6 +598,10 @@ append_cppflags(ENV["CPPFLAGS"].split) unless ENV["CPPFLAGS"].nil?
|
|
594
598
|
append_ldflags(ENV["LDFLAGS"].split) unless ENV["LDFLAGS"].nil?
|
595
599
|
$LIBS = concat_flags($LIBS, ENV["LIBS"])
|
596
600
|
|
601
|
+
# nokogumbo code uses C90/C99 features, let's make sure older compilers won't give
|
602
|
+
# errors/warnings. see #2302
|
603
|
+
append_cflags(["-std=c99", "-Wno-declaration-after-statement"])
|
604
|
+
|
597
605
|
# always include debugging information
|
598
606
|
append_cflags("-g")
|
599
607
|
|
@@ -652,7 +660,7 @@ else
|
|
652
660
|
if cross_build_p || windows?
|
653
661
|
zlib_recipe = process_recipe("zlib", dependencies["zlib"]["version"], static_p, cross_build_p) do |recipe|
|
654
662
|
recipe.files = [{
|
655
|
-
url: "
|
663
|
+
url: "https://zlib.net/fossils/#{recipe.name}-#{recipe.version}.tar.gz",
|
656
664
|
sha256: dependencies["zlib"]["sha256"],
|
657
665
|
}]
|
658
666
|
if windows?
|
@@ -696,7 +704,7 @@ else
|
|
696
704
|
end
|
697
705
|
|
698
706
|
def compile
|
699
|
-
if
|
707
|
+
if /darwin/.match?(host)
|
700
708
|
execute("compile", "make AR=#{host}-libtool")
|
701
709
|
else
|
702
710
|
super
|
@@ -710,10 +718,13 @@ else
|
|
710
718
|
libiconv_recipe = process_recipe("libiconv", dependencies["libiconv"]["version"], static_p,
|
711
719
|
cross_build_p) do |recipe|
|
712
720
|
recipe.files = [{
|
713
|
-
url: "
|
721
|
+
url: "https://ftp.gnu.org/pub/gnu/libiconv/#{recipe.name}-#{recipe.version}.tar.gz",
|
714
722
|
sha256: dependencies["libiconv"]["sha256"],
|
715
723
|
}]
|
716
724
|
|
725
|
+
# The libiconv configure script doesn't accept "arm64" host string but "aarch64"
|
726
|
+
recipe.host = recipe.host.gsub("arm64-apple-darwin", "aarch64-apple-darwin")
|
727
|
+
|
717
728
|
cflags = concat_flags(ENV["CFLAGS"], "-O2", "-U_FORTIFY_SOURCE", "-g")
|
718
729
|
|
719
730
|
recipe.configure_options += [
|
@@ -737,12 +748,21 @@ else
|
|
737
748
|
Tools" to open the developer site, download the installer for your OS
|
738
749
|
version and run it.
|
739
750
|
-----
|
740
|
-
|
751
|
+
EOM
|
741
752
|
end
|
742
753
|
|
743
|
-
|
744
|
-
|
745
|
-
|
754
|
+
if zlib_recipe
|
755
|
+
append_cppflags("-I#{zlib_recipe.path}/include")
|
756
|
+
$LIBPATH = ["#{zlib_recipe.path}/lib"] | $LIBPATH
|
757
|
+
ensure_package_configuration(opt: "zlib", pc: "zlib", lib: "z",
|
758
|
+
headers: "zlib.h", func: "gzdopen")
|
759
|
+
end
|
760
|
+
|
761
|
+
if libiconv_recipe
|
762
|
+
append_cppflags("-I#{libiconv_recipe.path}/include")
|
763
|
+
$LIBPATH = ["#{libiconv_recipe.path}/lib"] | $LIBPATH
|
764
|
+
ensure_package_configuration(opt: "iconv", pc: "iconv", lib: "iconv",
|
765
|
+
headers: "iconv.h", func: "iconv_open")
|
746
766
|
end
|
747
767
|
|
748
768
|
libxml2_recipe = process_recipe("libxml2", dependencies["libxml2"]["version"], static_p, cross_build_p) do |recipe|
|
@@ -761,7 +781,6 @@ else
|
|
761
781
|
|
762
782
|
if zlib_recipe
|
763
783
|
recipe.configure_options << "--with-zlib=#{zlib_recipe.path}"
|
764
|
-
cflags = concat_flags(cflags, "-I#{zlib_recipe.path}/include")
|
765
784
|
end
|
766
785
|
|
767
786
|
if libiconv_recipe
|
@@ -830,9 +849,6 @@ else
|
|
830
849
|
append_cppflags("-DNOKOGIRI_PACKAGED_LIBRARIES")
|
831
850
|
append_cppflags("-DNOKOGIRI_PRECOMPILED_LIBRARIES") if cross_build_p
|
832
851
|
|
833
|
-
$LIBPATH = ["#{zlib_recipe.path}/lib"] | $LIBPATH if zlib_recipe
|
834
|
-
$LIBPATH = ["#{libiconv_recipe.path}/lib"] | $LIBPATH if libiconv_recipe
|
835
|
-
|
836
852
|
$libs = $libs.shellsplit.tap do |libs|
|
837
853
|
[libxml2_recipe, libxslt_recipe].each do |recipe|
|
838
854
|
libname = recipe.name[/\Alib(.+)\z/, 1]
|
@@ -925,7 +941,7 @@ libgumbo_recipe = process_recipe("libgumbo", "1.0.0-nokogiri", static_p, cross_b
|
|
925
941
|
|
926
942
|
env = { "CC" => gcc_cmd, "CFLAGS" => cflags }
|
927
943
|
if config_cross_build?
|
928
|
-
if
|
944
|
+
if /darwin/.match?(host)
|
929
945
|
env["AR"] = "#{host}-libtool"
|
930
946
|
env["ARFLAGS"] = "-o"
|
931
947
|
else
|
data/ext/nokogiri/gumbo.c
CHANGED
@@ -75,7 +75,7 @@ new_html_doc(const char *dtd_name, const char *system, const char *public)
|
|
75
75
|
htmlDocPtr doc = htmlNewDocNoDtD(/* URI */ NULL, /* ExternalID */NULL);
|
76
76
|
assert(doc);
|
77
77
|
if (dtd_name) {
|
78
|
-
xmlCreateIntSubset(doc,
|
78
|
+
xmlCreateIntSubset(doc, (const xmlChar *)dtd_name, (const xmlChar *)public, (const xmlChar *)system);
|
79
79
|
}
|
80
80
|
return doc;
|
81
81
|
}
|
@@ -120,11 +120,11 @@ lookup_or_add_ns(
|
|
120
120
|
const char *prefix
|
121
121
|
)
|
122
122
|
{
|
123
|
-
xmlNsPtr ns = xmlSearchNs(doc, root,
|
123
|
+
xmlNsPtr ns = xmlSearchNs(doc, root, (const xmlChar *)prefix);
|
124
124
|
if (ns) {
|
125
125
|
return ns;
|
126
126
|
}
|
127
|
-
return xmlNewNs(root,
|
127
|
+
return xmlNewNs(root, (const xmlChar *)href, (const xmlChar *)prefix);
|
128
128
|
}
|
129
129
|
|
130
130
|
static void
|
@@ -181,20 +181,20 @@ build_tree(
|
|
181
181
|
|
182
182
|
case GUMBO_NODE_TEXT:
|
183
183
|
case GUMBO_NODE_WHITESPACE:
|
184
|
-
xml_child = xmlNewDocText(doc,
|
184
|
+
xml_child = xmlNewDocText(doc, (const xmlChar *)gumbo_child->v.text.text);
|
185
185
|
set_line(xml_child, gumbo_child->v.text.start_pos.line);
|
186
186
|
xmlAddChild(xml_node, xml_child);
|
187
187
|
break;
|
188
188
|
|
189
189
|
case GUMBO_NODE_CDATA:
|
190
|
-
xml_child = xmlNewCDataBlock(doc,
|
190
|
+
xml_child = xmlNewCDataBlock(doc, (const xmlChar *)gumbo_child->v.text.text,
|
191
191
|
(int) strlen(gumbo_child->v.text.text));
|
192
192
|
set_line(xml_child, gumbo_child->v.text.start_pos.line);
|
193
193
|
xmlAddChild(xml_node, xml_child);
|
194
194
|
break;
|
195
195
|
|
196
196
|
case GUMBO_NODE_COMMENT:
|
197
|
-
xml_child = xmlNewDocComment(doc,
|
197
|
+
xml_child = xmlNewDocComment(doc, (const xmlChar *)gumbo_child->v.text.text);
|
198
198
|
set_line(xml_child, gumbo_child->v.text.start_pos.line);
|
199
199
|
xmlAddChild(xml_node, xml_child);
|
200
200
|
break;
|
@@ -202,7 +202,7 @@ build_tree(
|
|
202
202
|
case GUMBO_NODE_TEMPLATE:
|
203
203
|
// XXX: Should create a template element and a new DocumentFragment
|
204
204
|
case GUMBO_NODE_ELEMENT: {
|
205
|
-
xml_child = xmlNewDocNode(doc, NULL,
|
205
|
+
xml_child = xmlNewDocNode(doc, NULL, (const xmlChar *)gumbo_child->v.element.name, NULL);
|
206
206
|
set_line(xml_child, gumbo_child->v.element.start_pos.line);
|
207
207
|
if (xml_root == NULL) {
|
208
208
|
xml_root = xml_child;
|
@@ -244,7 +244,7 @@ build_tree(
|
|
244
244
|
default:
|
245
245
|
ns = NULL;
|
246
246
|
}
|
247
|
-
xmlNewNsProp(xml_child, ns,
|
247
|
+
xmlNewNsProp(xml_child, ns, (const xmlChar *)attr->name, (const xmlChar *)attr->value);
|
248
248
|
}
|
249
249
|
|
250
250
|
// Add children for this element.
|
@@ -303,7 +303,7 @@ typedef struct {
|
|
303
303
|
static VALUE
|
304
304
|
parse_cleanup(VALUE parse_args)
|
305
305
|
{
|
306
|
-
ParseArgs *args = (ParseArgs*)parse_args;
|
306
|
+
ParseArgs *args = (ParseArgs *)parse_args;
|
307
307
|
gumbo_destroy_output(args->output);
|
308
308
|
// Make sure garbage collection doesn't mark the objects as being live based
|
309
309
|
// on references from the ParseArgs. This may be unnecessary.
|
@@ -342,7 +342,7 @@ parse(VALUE self, VALUE input, VALUE url, VALUE max_attributes, VALUE max_errors
|
|
342
342
|
static VALUE
|
343
343
|
parse_continue(VALUE parse_args)
|
344
344
|
{
|
345
|
-
ParseArgs *args = (ParseArgs*)parse_args;
|
345
|
+
ParseArgs *args = (ParseArgs *)parse_args;
|
346
346
|
GumboOutput *output = args->output;
|
347
347
|
xmlDocPtr doc;
|
348
348
|
if (output->document->v.document.has_doctype) {
|
@@ -552,7 +552,7 @@ error:
|
|
552
552
|
static VALUE
|
553
553
|
fragment_continue(VALUE parse_args)
|
554
554
|
{
|
555
|
-
ParseArgs *args = (ParseArgs*)parse_args;
|
555
|
+
ParseArgs *args = (ParseArgs *)parse_args;
|
556
556
|
GumboOutput *output = args->output;
|
557
557
|
VALUE doc_fragment = args->url_or_frag;
|
558
558
|
xmlDocPtr xml_doc = args->doc;
|
@@ -266,7 +266,7 @@ get_description(VALUE klass, VALUE tag_name)
|
|
266
266
|
);
|
267
267
|
|
268
268
|
if (NULL == description) { return Qnil; }
|
269
|
-
return Data_Wrap_Struct(klass, 0, 0, (void
|
269
|
+
return Data_Wrap_Struct(klass, 0, 0, DISCARD_CONST_QUAL(void *, description));
|
270
270
|
}
|
271
271
|
|
272
272
|
void
|
@@ -110,7 +110,8 @@ void
|
|
110
110
|
noko_init_html_sax_parser_context()
|
111
111
|
{
|
112
112
|
assert(cNokogiriXmlSaxParserContext);
|
113
|
-
cNokogiriHtml4SaxParserContext = rb_define_class_under(mNokogiriHtml4Sax, "ParserContext",
|
113
|
+
cNokogiriHtml4SaxParserContext = rb_define_class_under(mNokogiriHtml4Sax, "ParserContext",
|
114
|
+
cNokogiriXmlSaxParserContext);
|
114
115
|
|
115
116
|
rb_define_singleton_method(cNokogiriHtml4SaxParserContext, "memory", parse_memory, 2);
|
116
117
|
rb_define_singleton_method(cNokogiriHtml4SaxParserContext, "file", parse_file, 2);
|
data/ext/nokogiri/nokogiri.c
CHANGED
@@ -220,7 +220,7 @@ Init_nokogiri()
|
|
220
220
|
xmlInitParser();
|
221
221
|
exsltRegisterAll();
|
222
222
|
|
223
|
-
if (xsltExtModuleFunctionLookup((xmlChar*)"date-time", EXSLT_DATE_NAMESPACE)) {
|
223
|
+
if (xsltExtModuleFunctionLookup((const xmlChar *)"date-time", EXSLT_DATE_NAMESPACE)) {
|
224
224
|
rb_const_set(mNokogiri, rb_intern("LIBXSLT_DATETIME_ENABLED"), Qtrue);
|
225
225
|
} else {
|
226
226
|
rb_const_set(mNokogiri, rb_intern("LIBXSLT_DATETIME_ENABLED"), Qfalse);
|
data/ext/nokogiri/xml_document.c
CHANGED
@@ -213,7 +213,7 @@ set_encoding(VALUE self, VALUE encoding)
|
|
213
213
|
Data_Get_Struct(self, xmlDoc, doc);
|
214
214
|
|
215
215
|
if (doc->encoding) {
|
216
|
-
|
216
|
+
xmlFree(DISCARD_CONST_QUAL_XMLCHAR(doc->encoding));
|
217
217
|
}
|
218
218
|
|
219
219
|
doc->encoding = xmlStrdup((xmlChar *)StringValueCStr(encoding));
|
@@ -533,59 +533,59 @@ block_caller(void *ctx, xmlNodePtr c_node, xmlNodePtr c_parent_node)
|
|
533
533
|
static VALUE
|
534
534
|
rb_xml_document_canonicalize(int argc, VALUE *argv, VALUE self)
|
535
535
|
{
|
536
|
-
VALUE
|
537
|
-
VALUE
|
538
|
-
VALUE
|
539
|
-
xmlChar **
|
540
|
-
long ns_len, i;
|
536
|
+
VALUE rb_mode;
|
537
|
+
VALUE rb_namespaces;
|
538
|
+
VALUE rb_comments_p;
|
539
|
+
xmlChar **c_namespaces;
|
541
540
|
|
542
|
-
xmlDocPtr
|
543
|
-
xmlOutputBufferPtr
|
544
|
-
xmlC14NIsVisibleCallback
|
545
|
-
void *
|
541
|
+
xmlDocPtr c_doc;
|
542
|
+
xmlOutputBufferPtr c_obuf;
|
543
|
+
xmlC14NIsVisibleCallback c_callback_wrapper = NULL;
|
544
|
+
void *rb_callback = NULL;
|
546
545
|
|
547
546
|
VALUE rb_cStringIO;
|
548
|
-
VALUE
|
547
|
+
VALUE rb_io;
|
549
548
|
|
550
|
-
rb_scan_args(argc, argv, "03", &
|
549
|
+
rb_scan_args(argc, argv, "03", &rb_mode, &rb_namespaces, &rb_comments_p);
|
550
|
+
if (!NIL_P(rb_mode)) { Check_Type(rb_mode, T_FIXNUM); }
|
551
|
+
if (!NIL_P(rb_namespaces)) { Check_Type(rb_namespaces, T_ARRAY); }
|
551
552
|
|
552
|
-
Data_Get_Struct(self, xmlDoc,
|
553
|
+
Data_Get_Struct(self, xmlDoc, c_doc);
|
553
554
|
|
554
555
|
rb_cStringIO = rb_const_get_at(rb_cObject, rb_intern("StringIO"));
|
555
|
-
|
556
|
-
|
556
|
+
rb_io = rb_class_new_instance(0, 0, rb_cStringIO);
|
557
|
+
c_obuf = xmlAllocOutputBuffer(NULL);
|
557
558
|
|
558
|
-
|
559
|
-
|
560
|
-
|
559
|
+
c_obuf->writecallback = (xmlOutputWriteCallback)noko_io_write;
|
560
|
+
c_obuf->closecallback = (xmlOutputCloseCallback)noko_io_close;
|
561
|
+
c_obuf->context = (void *)rb_io;
|
561
562
|
|
562
563
|
if (rb_block_given_p()) {
|
563
|
-
|
564
|
-
|
564
|
+
c_callback_wrapper = block_caller;
|
565
|
+
rb_callback = (void *)rb_block_proc();
|
565
566
|
}
|
566
567
|
|
567
|
-
if (NIL_P(
|
568
|
-
|
568
|
+
if (NIL_P(rb_namespaces)) {
|
569
|
+
c_namespaces = NULL;
|
569
570
|
} else {
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
ns[i] = (xmlChar *)StringValueCStr(entry);
|
571
|
+
long ns_len = RARRAY_LEN(rb_namespaces);
|
572
|
+
c_namespaces = calloc((size_t)ns_len + 1, sizeof(xmlChar *));
|
573
|
+
for (int j = 0 ; j < ns_len ; j++) {
|
574
|
+
VALUE entry = rb_ary_entry(rb_namespaces, j);
|
575
|
+
c_namespaces[j] = (xmlChar *)StringValueCStr(entry);
|
576
576
|
}
|
577
577
|
}
|
578
578
|
|
579
|
+
xmlC14NExecute(c_doc, c_callback_wrapper, rb_callback,
|
580
|
+
(int)(NIL_P(rb_mode) ? 0 : NUM2INT(rb_mode)),
|
581
|
+
c_namespaces,
|
582
|
+
(int)RTEST(rb_comments_p),
|
583
|
+
c_obuf);
|
579
584
|
|
580
|
-
|
581
|
-
|
582
|
-
ns,
|
583
|
-
(int) RTEST(with_comments),
|
584
|
-
buf);
|
585
|
-
|
586
|
-
xmlOutputBufferClose(buf);
|
585
|
+
free(c_namespaces);
|
586
|
+
xmlOutputBufferClose(c_obuf);
|
587
587
|
|
588
|
-
return rb_funcall(
|
588
|
+
return rb_funcall(rb_io, rb_intern("string"), 0);
|
589
589
|
}
|
590
590
|
|
591
591
|
VALUE
|
data/ext/nokogiri/xml_dtd.c
CHANGED
@@ -57,9 +57,9 @@ entities(VALUE self)
|
|
57
57
|
|
58
58
|
/*
|
59
59
|
* call-seq:
|
60
|
-
* notations
|
60
|
+
* notations() → Hash<name(String)⇒Notation>
|
61
61
|
*
|
62
|
-
*
|
62
|
+
* [Returns] All the notations for this DTD in a Hash of Notation +name+ to Notation.
|
63
63
|
*/
|
64
64
|
static VALUE
|
65
65
|
notations(VALUE self)
|
@@ -3,70 +3,82 @@
|
|
3
3
|
VALUE cNokogiriEncodingHandler;
|
4
4
|
|
5
5
|
|
6
|
+
static void
|
7
|
+
_xml_encoding_handler_dealloc(xmlCharEncodingHandlerPtr c_handler)
|
8
|
+
{
|
9
|
+
/* make sure iconv handlers are cleaned up and freed */
|
10
|
+
xmlCharEncCloseFunc(c_handler);
|
11
|
+
}
|
12
|
+
|
13
|
+
|
6
14
|
/*
|
7
15
|
* call-seq: Nokogiri::EncodingHandler.[](name)
|
8
16
|
*
|
9
17
|
* Get the encoding handler for +name+
|
10
18
|
*/
|
11
19
|
static VALUE
|
12
|
-
|
20
|
+
rb_xml_encoding_handler_s_get(VALUE klass, VALUE key)
|
13
21
|
{
|
14
22
|
xmlCharEncodingHandlerPtr handler;
|
15
23
|
|
16
24
|
handler = xmlFindCharEncodingHandler(StringValueCStr(key));
|
17
25
|
if (handler) {
|
18
|
-
return Data_Wrap_Struct(klass, NULL,
|
26
|
+
return Data_Wrap_Struct(klass, NULL, _xml_encoding_handler_dealloc, handler);
|
19
27
|
}
|
20
28
|
|
21
29
|
return Qnil;
|
22
30
|
}
|
23
31
|
|
32
|
+
|
24
33
|
/*
|
25
34
|
* call-seq: Nokogiri::EncodingHandler.delete(name)
|
26
35
|
*
|
27
36
|
* Delete the encoding alias named +name+
|
28
37
|
*/
|
29
38
|
static VALUE
|
30
|
-
|
39
|
+
rb_xml_encoding_handler_s_delete(VALUE klass, VALUE name)
|
31
40
|
{
|
32
41
|
if (xmlDelEncodingAlias(StringValueCStr(name))) { return Qnil; }
|
33
42
|
|
34
43
|
return Qtrue;
|
35
44
|
}
|
36
45
|
|
46
|
+
|
37
47
|
/*
|
38
48
|
* call-seq: Nokogiri::EncodingHandler.alias(from, to)
|
39
49
|
*
|
40
50
|
* Alias encoding handler with name +from+ to name +to+
|
41
51
|
*/
|
42
52
|
static VALUE
|
43
|
-
|
53
|
+
rb_xml_encoding_handler_s_alias(VALUE klass, VALUE from, VALUE to)
|
44
54
|
{
|
45
55
|
xmlAddEncodingAlias(StringValueCStr(from), StringValueCStr(to));
|
46
56
|
|
47
57
|
return to;
|
48
58
|
}
|
49
59
|
|
60
|
+
|
50
61
|
/*
|
51
62
|
* call-seq: Nokogiri::EncodingHandler.clear_aliases!
|
52
63
|
*
|
53
64
|
* Remove all encoding aliases.
|
54
65
|
*/
|
55
66
|
static VALUE
|
56
|
-
|
67
|
+
rb_xml_encoding_handler_s_clear_aliases(VALUE klass)
|
57
68
|
{
|
58
69
|
xmlCleanupEncodingAliases();
|
59
70
|
|
60
71
|
return klass;
|
61
72
|
}
|
62
73
|
|
74
|
+
|
63
75
|
/*
|
64
76
|
* call-seq: name
|
65
77
|
*
|
66
78
|
* Get the name of this EncodingHandler
|
67
79
|
*/
|
68
80
|
static VALUE
|
69
|
-
|
81
|
+
rb_xml_encoding_handler_name(VALUE self)
|
70
82
|
{
|
71
83
|
xmlCharEncodingHandlerPtr handler;
|
72
84
|
|
@@ -75,6 +87,7 @@ name(VALUE self)
|
|
75
87
|
return NOKOGIRI_STR_NEW2(handler->name);
|
76
88
|
}
|
77
89
|
|
90
|
+
|
78
91
|
void
|
79
92
|
noko_init_xml_encoding_handler()
|
80
93
|
{
|
@@ -82,9 +95,10 @@ noko_init_xml_encoding_handler()
|
|
82
95
|
|
83
96
|
rb_undef_alloc_func(cNokogiriEncodingHandler);
|
84
97
|
|
85
|
-
rb_define_singleton_method(cNokogiriEncodingHandler, "[]",
|
86
|
-
rb_define_singleton_method(cNokogiriEncodingHandler, "delete",
|
87
|
-
rb_define_singleton_method(cNokogiriEncodingHandler, "alias",
|
88
|
-
rb_define_singleton_method(cNokogiriEncodingHandler, "clear_aliases!",
|
89
|
-
|
98
|
+
rb_define_singleton_method(cNokogiriEncodingHandler, "[]", rb_xml_encoding_handler_s_get, 1);
|
99
|
+
rb_define_singleton_method(cNokogiriEncodingHandler, "delete", rb_xml_encoding_handler_s_delete, 1);
|
100
|
+
rb_define_singleton_method(cNokogiriEncodingHandler, "alias", rb_xml_encoding_handler_s_alias, 2);
|
101
|
+
rb_define_singleton_method(cNokogiriEncodingHandler, "clear_aliases!", rb_xml_encoding_handler_s_clear_aliases, 0);
|
102
|
+
|
103
|
+
rb_define_method(cNokogiriEncodingHandler, "name", rb_xml_encoding_handler_name, 0);
|
90
104
|
}
|