nokogiri 1.6.6.4-java → 1.6.7-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.

Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/.cross_rubies +7 -5
  3. data/.travis.yml +33 -30
  4. data/CHANGELOG.ja.rdoc +38 -6
  5. data/CHANGELOG.rdoc +33 -1
  6. data/Gemfile +3 -2
  7. data/LICENSE.txt +31 -0
  8. data/Manifest.txt +4 -24
  9. data/README.md +170 -0
  10. data/Rakefile +25 -22
  11. data/appveyor.yml +22 -0
  12. data/build_all +6 -90
  13. data/ext/java/nokogiri/XmlDocument.java +5 -0
  14. data/ext/java/nokogiri/XmlNode.java +16 -1
  15. data/ext/java/nokogiri/XmlSaxPushParser.java +6 -2
  16. data/ext/java/nokogiri/XmlSchema.java +20 -20
  17. data/ext/java/nokogiri/internals/NokogiriHandler.java +21 -15
  18. data/ext/java/nokogiri/internals/ParserContext.java +15 -11
  19. data/ext/nokogiri/extconf.rb +37 -34
  20. data/ext/nokogiri/xml_node.c +21 -11
  21. data/ext/nokogiri/xml_sax_parser_context.c +2 -2
  22. data/lib/nokogiri/nokogiri.jar +0 -0
  23. data/lib/nokogiri/version.rb +1 -1
  24. data/lib/nokogiri/xml/node.rb +16 -0
  25. data/{ports/patches → patches}/sort-patches-by-date +0 -0
  26. data/test/html/test_document.rb +26 -3
  27. data/test/xml/sax/test_parser.rb +11 -0
  28. data/test/xml/test_document.rb +11 -0
  29. data/test/xml/test_schema.rb +15 -2
  30. data/test/xml/test_xpath.rb +15 -0
  31. metadata +28 -33
  32. data/README.ja.rdoc +0 -112
  33. data/README.rdoc +0 -177
  34. data/ports/patches/libxml2/0001-Revert-Missing-initialization-for-the-catalog-module.patch +0 -29
  35. data/ports/patches/libxml2/0002-Fix-missing-entities-after-CVE-2014-3660-fix.patch +0 -31
  36. data/ports/patches/libxml2/0003-Stop-parsing-on-entities-boundaries-errors.patch +0 -32
  37. data/ports/patches/libxml2/0004-Cleanup-conditional-section-error-handling.patch +0 -49
  38. data/ports/patches/libxml2/0005-CVE-2015-1819-Enforce-the-reader-to-run-in-constant-.patch +0 -177
  39. data/ports/patches/libxml2/0006-Another-variation-of-overflow-in-Conditional-section.patch +0 -32
  40. data/ports/patches/libxml2/0007-Fix-an-error-in-previous-Conditional-section-patch.patch +0 -28
  41. data/ports/patches/libxml2/0008-CVE-2015-8035-Fix-XZ-compression-support-loop.patch +0 -31
  42. data/ports/patches/libxslt/0001-Adding-doc-update-related-to-1.1.28.patch +0 -222
  43. data/ports/patches/libxslt/0002-Fix-a-couple-of-places-where-f-printf-parameters-wer.patch +0 -53
  44. data/ports/patches/libxslt/0003-Initialize-pseudo-random-number-generator-with-curre.patch +0 -60
  45. data/ports/patches/libxslt/0004-EXSLT-function-str-replace-is-broken-as-is.patch +0 -42
  46. data/ports/patches/libxslt/0006-Fix-str-padding-to-work-with-UTF-8-strings.patch +0 -164
  47. data/ports/patches/libxslt/0007-Separate-function-for-predicate-matching-in-patterns.patch +0 -587
  48. data/ports/patches/libxslt/0008-Fix-direct-pattern-matching.patch +0 -80
  49. data/ports/patches/libxslt/0009-Fix-certain-patterns-with-predicates.patch +0 -185
  50. data/ports/patches/libxslt/0010-Fix-handling-of-UTF-8-strings-in-EXSLT-crypto-module.patch +0 -126
  51. data/ports/patches/libxslt/0013-Memory-leak-in-xsltCompileIdKeyPattern-error-path.patch +0 -25
  52. data/ports/patches/libxslt/0014-Fix-for-bug-436589.patch +0 -43
  53. data/ports/patches/libxslt/0015-Fix-mkdir-for-mingw.patch +0 -41
  54. data/ports/patches/libxslt/0016-Fix-for-type-confusion-in-preprocessing-attributes.patch +0 -29
data/Rakefile CHANGED
@@ -12,7 +12,6 @@ Hoe.add_include_dirs '.'
12
12
 
13
13
  GENERATED_PARSER = "lib/nokogiri/css/parser.rb"
14
14
  GENERATED_TOKENIZER = "lib/nokogiri/css/tokenizer.rb"
15
- CROSS_DIR = File.join(File.dirname(__FILE__), 'ports')
16
15
 
17
16
  def java?
18
17
  /java/ === RUBY_PLATFORM
@@ -25,14 +24,18 @@ CrossRuby = Struct.new(:version, :host) {
25
24
  @ver ||= version[/\A[^-]+/]
26
25
  end
27
26
 
27
+ def minor_ver
28
+ @minor_ver ||= ver[/\A\d\.\d(?=\.)/]
29
+ end
30
+
28
31
  def api_ver_suffix
29
- case ver
30
- when /\A([2-9])\.([0-9])\./
31
- "#{$1}#{$2}0"
32
- when /\A1\.9\./
32
+ case minor_ver
33
+ when nil
34
+ raise "unsupported version: #{ver}"
35
+ when '1.9'
33
36
  '191'
34
37
  else
35
- raise "unsupported version: #{ver}"
38
+ minor_ver.delete('.') << '0'
36
39
  end
37
40
  end
38
41
 
@@ -110,7 +113,7 @@ HOE = Hoe.spec 'nokogiri' do
110
113
 
111
114
  license "MIT"
112
115
 
113
- self.readme_file = ['README', ENV['HLANG'], 'rdoc'].compact.join('.')
116
+ self.readme_file = "README.md"
114
117
  self.history_file = ['CHANGELOG', ENV['HLANG'], 'rdoc'].compact.join('.')
115
118
 
116
119
  self.extra_rdoc_files = FileList['*.rdoc','ext/nokogiri/*.c']
@@ -119,22 +122,14 @@ HOE = Hoe.spec 'nokogiri' do
119
122
  self.clean_globs += [
120
123
  'nokogiri.gemspec',
121
124
  'lib/nokogiri/nokogiri.{bundle,jar,rb,so}',
122
- 'lib/nokogiri/[0-9].[0-9]',
123
- 'ports/*.installed',
124
- 'ports/{i[3-6]86,x86_64}-{w64-,}mingw32*',
125
- 'ports/libxml2',
126
- 'ports/libxslt',
127
- # GENERATED_PARSER,
128
- # GENERATED_TOKENIZER
125
+ 'lib/nokogiri/[0-9].[0-9]'
129
126
  ]
127
+ self.clean_globs += Dir.glob("ports/*").reject { |d| d =~ %r{/archives$} }
130
128
 
131
129
  unless java?
132
130
  self.extra_deps += [
133
- # this dependency locked because we're monkey-punching mini_portile.
134
- # for more details, see:
135
- # - https://github.com/sparklemotion/nokogiri/issues/1102
136
- # - https://github.com/luislavena/mini_portile/issues/32
137
- ["mini_portile", "~> 0.6.0"],
131
+ # Keep this version in sync with the one in extconf.rb !
132
+ ["mini_portile2", "~> 2.0.0.rc2"],
138
133
  ]
139
134
  end
140
135
 
@@ -146,6 +141,7 @@ HOE = Hoe.spec 'nokogiri' do
146
141
  ["minitest", "~> 2.2.2"],
147
142
  ["rake", ">= 0.9"],
148
143
  ["rake-compiler", "~> 0.9.2"],
144
+ ["rake-compiler-dock", "~> 0.4.2"],
149
145
  ["racc", ">= 1.4.6"],
150
146
  ["rexical", ">= 1.0.5"]
151
147
  ]
@@ -200,7 +196,6 @@ else
200
196
  Rake::ExtensionCompiler.mingw_host
201
197
  mingw_available = true
202
198
  rescue
203
- puts "WARNING: cross compilation not available: #{$!}"
204
199
  mingw_available = false
205
200
  end
206
201
  require "rake/extensiontask"
@@ -214,7 +209,7 @@ else
214
209
  version = dependencies[lib]
215
210
  archive = File.join("ports", "archives", "#{lib}-#{version}.tar.gz")
216
211
  add_file_to_gem archive
217
- patchesdir = File.join("ports", "patches", lib)
212
+ patchesdir = File.join("patches", lib)
218
213
  patches = `#{['git', 'ls-files', patchesdir].shelljoin}`.split("\n").grep(/\.patch\z/)
219
214
  patches.each { |patch|
220
215
  add_file_to_gem patch
@@ -238,6 +233,11 @@ else
238
233
  ext.cross_compiling do |spec|
239
234
  libs = dependencies.map { |name, version| "#{name}-#{version}" }.join(', ')
240
235
 
236
+ spec.required_ruby_version = [
237
+ '>= 1.9.2',
238
+ "< #{CROSS_RUBIES.max_by(&:ver).minor_ver.succ}"
239
+ ]
240
+
241
241
  spec.post_install_message = <<-EOS
242
242
  Nokogiri is built with the packaged libraries: #{libs}.
243
243
  EOS
@@ -349,6 +349,9 @@ task :cross do
349
349
  end
350
350
 
351
351
  desc "build a windows gem without all the ceremony."
352
- task "gem:windows" => %w[cross native gem]
352
+ task "gem:windows" do
353
+ require "rake_compiler_dock"
354
+ RakeCompilerDock.sh "bundle && rake cross native gem MAKE='nice make -j`nproc`' RUBY_CC_VERSION=#{ENV['RUBY_CC_VERSION']}"
355
+ end
353
356
 
354
357
  # vim: syntax=Ruby
data/appveyor.yml ADDED
@@ -0,0 +1,22 @@
1
+ install:
2
+ - SET PATH=C:\Ruby%ruby_version%\bin;%PATH%
3
+ - SET PATH=C:\MinGW\bin;%PATH%
4
+ - SET RAKEOPT=-rdevkit
5
+ - ruby --version
6
+ - gem --version
7
+ - bundle install
8
+
9
+ build: off
10
+
11
+ test_script:
12
+ - bundle exec rake
13
+
14
+ environment:
15
+ matrix:
16
+ - ruby_version: "22"
17
+ - ruby_version: "22-x64"
18
+ - ruby_version: "21"
19
+ - ruby_version: "21-x64"
20
+ - ruby_version: "200"
21
+ - ruby_version: "200-x64"
22
+ - ruby_version: "193"
data/build_all CHANGED
@@ -5,43 +5,6 @@
5
5
  # - windows (x86-mingw32 and x64-mingw32)
6
6
  # - jruby
7
7
  #
8
- # here's what I recommend for building all the gems:
9
- #
10
- # set up a rake-compiler-dev-box as described here:
11
- # https://github.com/tjschuck/rake-compiler-dev-box
12
- # It is prepared with all the necessary build tools and environments.
13
- #
14
- # or alternatively do:
15
- # 1. Setup a ubuntu 12.04+ machine
16
- # 2. install rvm, and install 1.9.3, 2.0.0 and jruby.
17
- # 3. `sudo apt-get install mingw32 gcc-mingw-w64-i686 gcc-mingw-w64-x86-64`
18
- #
19
- # as you build, you may run into these problems:
20
- #
21
- # - if you're using Virtualbox shared directories, you'll get a mingw
22
- # "Protocol error" at linktime. Boo! Either use NFS or a
23
- # locally-checked-out repository.
24
- #
25
- # - on ubuntus 11 and later, you may have issues with building
26
- # rake-compiler's rubies against openssl v2. Just comment the lines
27
- # out from ossl_ssl.c and you'll be fine.
28
- #
29
- # - you may have issues with Pathname conversion to String in
30
- # bundler. Add this to the offending bundler file:
31
- #
32
- # class Pathname
33
- # def to_str
34
- # to_s
35
- # end
36
- # end
37
- #
38
- # - you may also have to hack rubygems.rb to eliminate a reference to
39
- # RUBY_ENGINE (just comment it out)
40
- #
41
-
42
- DEFAULT_RUBY=2.0.0
43
-
44
- HOST=
45
8
 
46
9
  # Load RVM into a shell session *as a function*
47
10
  if [[ -s "$HOME/.rvm/scripts/rvm" ]] ; then
@@ -52,63 +15,17 @@ else
52
15
  echo "ERROR: An RVM installation was not found.\n"
53
16
  fi
54
17
 
55
- rvm_use () {
56
- current_ruby=$1
57
- rvm use "${1}@nokogiri" --create
58
- }
59
-
60
- rvm_do () {
61
- local ver=$1
62
- shift
63
- rvm "${ver}@nokogiri" do "$@"
64
- }
65
-
66
- cross_rubies () {
67
- grep -v '#' .cross_rubies
68
- }
69
-
70
- ruby_vers () {
71
- cross_rubies | while read -r line; do
72
- echo "${line%%[-:]*}"
73
- done | uniq
74
- }
75
-
76
18
  set -o errexit
77
-
78
- for ver in `ruby_vers`; do
79
- rvm_use $ver
80
- gem install bundler --conservative
81
- bundle install --quiet --local || bundle install
82
- done
83
-
84
- rvm_use $DEFAULT_RUBY
19
+ set -x
85
20
 
86
21
  rm -rf tmp pkg
87
- bundle exec rake clean
22
+ bundle exec rake clean clobber
88
23
 
89
24
  # holding pen
90
25
  rm -rf gems
91
26
  mkdir -p gems
92
27
 
93
28
  # windows
94
- for verspec in `cross_rubies`; do
95
- version="${verspec%%:*}"
96
- ver="${version%%-*}"
97
- host="${verspec#*:}"
98
-
99
- case $ver in
100
- 1.9.3)
101
- # Parallel make does not work in 1.9.3, as it has a
102
- # missing dependency problem with main.o.
103
- make="make"
104
- ;;
105
- *)
106
- make="$MAKE"
107
- esac
108
-
109
- MAKE="$make" rvm_do $ver rake-compiler cross-ruby VERSION=$version HOST=$host debugflags="-g"
110
- done
111
-
112
29
  bundle exec rake gem:windows
113
30
  cp -v pkg/nokogiri*{x86,x64}-mingw32*.gem gems
114
31
 
@@ -118,12 +35,11 @@ bundle exec rake gem
118
35
  cp -v pkg/nokogiri*.gem gems
119
36
 
120
37
  # jruby
121
- rvm_use jruby
122
- gem install bundler --conservative
123
- bundle install --quiet --local || bundle install
124
38
  bundle exec rake clean clobber
125
- rvm_use $DEFAULT_RUBY
126
39
  bundle exec rake generate
127
- rvm_use jruby
40
+
41
+ rvm jruby-1.7.19
42
+ gem install bundler --conservative
43
+ bundle install --quiet --local || bundle install
128
44
  bundle exec rake gem
129
45
  cp -v pkg/nokogiri*java.gem gems
@@ -639,4 +639,9 @@ public class XmlDocument extends XmlNode {
639
639
  }
640
640
  return this;
641
641
  }
642
+
643
+ public void resetNamespaceCache(ThreadContext context) {
644
+ nsCache = new NokogiriNamespaceCache();
645
+ createAndCacheNamespaces(context.getRuntime(), node);
646
+ }
642
647
  }
@@ -1055,7 +1055,18 @@ public class XmlNode extends RubyObject {
1055
1055
  if (node instanceof Element) {
1056
1056
  String key = rubyStringToString(rbkey);
1057
1057
  Element element = (Element) node;
1058
- return context.getRuntime().newBoolean(element.hasAttribute(key));
1058
+ if (element.hasAttribute(key)) {
1059
+ return context.getRuntime().getTrue();
1060
+ } else {
1061
+ NamedNodeMap namedNodeMap = element.getAttributes();
1062
+ for (int i=0; i<namedNodeMap.getLength(); i++) {
1063
+ Node n = namedNodeMap.item(i);
1064
+ if (key.equals(n.getLocalName())) {
1065
+ return context.getRuntime().getTrue();
1066
+ }
1067
+ }
1068
+ }
1069
+ return context.getRuntime().getFalse();
1059
1070
  } else {
1060
1071
  return context.getRuntime().getNil();
1061
1072
  }
@@ -1540,6 +1551,10 @@ public class XmlNode extends RubyObject {
1540
1551
  coalesceTextNodes(context, other, scheme);
1541
1552
  }
1542
1553
 
1554
+ if (this instanceof XmlDocument) {
1555
+ ((XmlDocument) this).resetNamespaceCache(context);
1556
+ }
1557
+
1543
1558
  relink_namespace(context);
1544
1559
  // post_add_child(context, this, other);
1545
1560
 
@@ -58,6 +58,7 @@ import org.jruby.anno.JRubyMethod;
58
58
  import org.jruby.exceptions.RaiseException;
59
59
  import org.jruby.runtime.ThreadContext;
60
60
  import org.jruby.runtime.builtin.IRubyObject;
61
+ import org.xml.sax.SAXException;
61
62
 
62
63
  /**
63
64
  * Class for Nokogiri::XML::SAX::PushParser
@@ -136,8 +137,11 @@ public class XmlSaxPushParser extends RubyObject {
136
137
 
137
138
 
138
139
  if (isLast.isTrue()) {
139
- IRubyObject document = invoke(context, this, "document");
140
- invoke(context, document, "end_document");
140
+ try {
141
+ parserTask.parser.getNokogiriHandler().endDocument();
142
+ } catch (SAXException e) {
143
+ throw context.getRuntime().newRuntimeError(e.getMessage());
144
+ }
141
145
  terminateTask(context);
142
146
  } else {
143
147
  try {
@@ -17,10 +17,10 @@
17
17
  * distribute, sublicense, and/or sell copies of the Software, and to
18
18
  * permit persons to whom the Software is furnished to do so, subject to
19
19
  * the following conditions:
20
- *
20
+ *
21
21
  * The above copyright notice and this permission notice shall be
22
22
  * included in all copies or substantial portions of the Software.
23
- *
23
+ *
24
24
  * THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
25
25
  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26
26
  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
@@ -71,7 +71,7 @@ import org.xml.sax.SAXException;
71
71
 
72
72
  /**
73
73
  * Class for Nokogiri::XML::Schema
74
- *
74
+ *
75
75
  * @author sergio
76
76
  * @author Yoko Harada <yokolet@gmail.com>
77
77
  */
@@ -82,7 +82,7 @@ public class XmlSchema extends RubyObject {
82
82
  public XmlSchema(Ruby ruby, RubyClass klazz) {
83
83
  super(ruby, klazz);
84
84
  }
85
-
85
+
86
86
  /**
87
87
  * Create and return a copy of this object.
88
88
  *
@@ -100,7 +100,7 @@ public class XmlSchema extends RubyObject {
100
100
  schemaFactory.setErrorHandler(new IgnoreSchemaErrorsErrorHandler());
101
101
  return schemaFactory.newSchema(source);
102
102
  }
103
-
103
+
104
104
  private void setValidator(Validator validator) {
105
105
  this.validator = validator;
106
106
  }
@@ -109,7 +109,7 @@ public class XmlSchema extends RubyObject {
109
109
  Ruby runtime = context.getRuntime();
110
110
  XmlSchema xmlSchema = (XmlSchema) NokogiriService.XML_SCHEMA_ALLOCATOR.allocate(runtime, klazz);
111
111
  xmlSchema.setInstanceVariable("@errors", runtime.newEmptyArray());
112
-
112
+
113
113
  try {
114
114
  Schema schema = xmlSchema.getSchema(source, context.getRuntime().getCurrentDirectory(), context.getRuntime().getInstanceConfig().getScriptFileName());
115
115
  xmlSchema.setValidator(schema.newValidator());
@@ -137,14 +137,14 @@ public class XmlSchema extends RubyObject {
137
137
  DOMSource source = new DOMSource(doc.getDocument());
138
138
 
139
139
  IRubyObject uri = doc.url(context);
140
-
140
+
141
141
  if (!uri.isNil()) {
142
142
  source.setSystemId(uri.convertToString().asJavaString());
143
143
  }
144
-
144
+
145
145
  return getSchema(context, (RubyClass)klazz, source);
146
146
  }
147
-
147
+
148
148
  private static IRubyObject getSchema(ThreadContext context, RubyClass klazz, Source source) {
149
149
  String moduleName = klazz.getName();
150
150
  if ("Nokogiri::XML::Schema".equals(moduleName)) {
@@ -165,17 +165,17 @@ public class XmlSchema extends RubyObject {
165
165
  public IRubyObject validate_document(ThreadContext context, IRubyObject document) {
166
166
  return validate_document_or_file(context, (XmlDocument)document);
167
167
  }
168
-
168
+
169
169
  @JRubyMethod(visibility=Visibility.PRIVATE)
170
170
  public IRubyObject validate_file(ThreadContext context, IRubyObject file) {
171
171
  Ruby ruby = context.getRuntime();
172
172
 
173
173
  XmlDomParserContext ctx = new XmlDomParserContext(ruby, RubyFixnum.newFixnum(ruby, 1L));
174
- ctx.setInputSource(context, file, context.getRuntime().getNil());
174
+ ctx.setInputSourceFile(context, file);
175
175
  XmlDocument xmlDocument = ctx.parse(context, getNokogiriClass(ruby, "Nokogiri::XML::Document"), ruby.getNil());
176
176
  return validate_document_or_file(context, xmlDocument);
177
177
  }
178
-
178
+
179
179
  IRubyObject validate_document_or_file(ThreadContext context, XmlDocument xmlDocument) {
180
180
  RubyArray errors = (RubyArray) this.getInstanceVariable("@errors");
181
181
  ErrorHandler errorHandler = new SchemaErrorHandler(context.getRuntime(), errors);
@@ -193,22 +193,22 @@ public class XmlSchema extends RubyObject {
193
193
 
194
194
  return errors;
195
195
  }
196
-
196
+
197
197
  protected void setErrorHandler(ErrorHandler errorHandler) {
198
198
  validator.setErrorHandler(errorHandler);
199
199
  }
200
-
200
+
201
201
  protected void validate(Document document) throws SAXException, IOException {
202
202
  DOMSource docSource = new DOMSource(document);
203
203
  validator.validate(docSource);
204
204
  }
205
-
205
+
206
206
  private class SchemaResourceResolver implements LSResourceResolver {
207
207
  SchemaLSInput lsInput = new SchemaLSInput();
208
208
  String currentDir;
209
209
  String scriptFileName;
210
210
  //String defaultURI;
211
-
211
+
212
212
  SchemaResourceResolver(String currentDir, String scriptFileName, Object input) {
213
213
  this.currentDir = currentDir;
214
214
  this.scriptFileName = scriptFileName;
@@ -231,7 +231,7 @@ public class XmlSchema extends RubyObject {
231
231
  return lsInput;
232
232
  }
233
233
  }
234
-
234
+
235
235
  private class SchemaLSInput implements LSInput {
236
236
  protected String fPublicId;
237
237
  protected String fSystemId;
@@ -241,7 +241,7 @@ public class XmlSchema extends RubyObject {
241
241
  protected String fData;
242
242
  protected String fEncoding;
243
243
  protected boolean fCertifiedText = false;
244
-
244
+
245
245
  @Override
246
246
  public String getBaseURI() {
247
247
  return fBaseSystemId;
@@ -289,7 +289,7 @@ public class XmlSchema extends RubyObject {
289
289
 
290
290
  @Override
291
291
  public void setByteStream(InputStream byteStream) {
292
- fByteStream = byteStream;
292
+ fByteStream = byteStream;
293
293
  }
294
294
 
295
295
  @Override
@@ -321,6 +321,6 @@ public class XmlSchema extends RubyObject {
321
321
  public void setSystemId(String sysId) {
322
322
  fSystemId = sysId;
323
323
  }
324
-
324
+
325
325
  }
326
326
  }