diff --git a/CVE-2020-26247-pre.patch b/CVE-2020-26247-pre.patch deleted file mode 100644 index 4605d1d1bf0d22d66f0c0edc38828f0bf642e7ce..0000000000000000000000000000000000000000 --- a/CVE-2020-26247-pre.patch +++ /dev/null @@ -1,65 +0,0 @@ -From 74abb4f2e73bb61b17d9f1a0ad717c881943b877 Mon Sep 17 00:00:00 2001 -From: Aaron Patterson -Date: Wed, 26 Feb 2020 13:51:43 -0800 -Subject: [PATCH] Work around a bug in libxml2 - -This commit works around a bug in libxml2 where parsing schemas can -result in dangling pointers which can lead to a segv. - -Upstream bug is here: https://gitlab.gnome.org/GNOME/libxml2/issues/148 - -Fixes #1985 ---- - ext/nokogiri/xml_schema.c | 29 +++++++++++++++++++++++++++++ - 1 file changed, 29 insertions(+) - -diff --git a/ext/nokogiri/xml_schema.c b/ext/nokogiri/xml_schema.c -index da2774b..439f721 100644 ---- a/ext/nokogiri/xml_schema.c -+++ b/ext/nokogiri/xml_schema.c -@@ -133,6 +133,31 @@ static VALUE read_memory(VALUE klass, VALUE content) - return rb_schema; - } - -+/* Schema creation will remove and deallocate "blank" nodes. -+ * If those blank nodes have been exposed to Ruby, they could get freed -+ * out from under the VALUE pointer. This function checks to see if any of -+ * those nodes have been exposed to Ruby, and if so we should raise an exception. -+ */ -+static int has_blank_nodes_p(VALUE cache) -+{ -+ long i; -+ -+ if (NIL_P(cache)) { -+ return 0; -+ } -+ -+ for (i = 0; i < RARRAY_LEN(cache); i++) { -+ xmlNodePtr node; -+ VALUE element = rb_ary_entry(cache, i); -+ Data_Get_Struct(element, xmlNode, node); -+ if (xmlIsBlankNode(node)) { -+ return 1; -+ } -+ } -+ -+ return 0; -+} -+ - /* - * call-seq: - * from_document(doc) -@@ -152,6 +177,10 @@ static VALUE from_document(VALUE klass, VALUE document) - /* In case someone passes us a node. ugh. */ - doc = doc->doc; - -+ if (has_blank_nodes_p(DOC_NODE_CACHE(doc))) { -+ rb_raise(rb_eArgError, "Creating a schema from a document that has blank nodes exposed to Ruby is dangerous"); -+ } -+ - ctx = xmlSchemaNewDocParserCtxt(doc); - - errors = rb_ary_new(); --- -2.23.0 - diff --git a/CVE-2020-26247.patch b/CVE-2020-26247.patch deleted file mode 100644 index e2a9a1c925625aac1c0dda873d915b3277a1efce..0000000000000000000000000000000000000000 --- a/CVE-2020-26247.patch +++ /dev/null @@ -1,278 +0,0 @@ -From 9c87439d9afa14a365ff13e73adc809cb2c3d97b Mon Sep 17 00:00:00 2001 -From: Mike Dalessio -Date: Mon, 23 Nov 2020 00:47:02 -0500 -Subject: [PATCH] feat: XML::Schema and RelaxNG creation accept optional - ParseOptions - -I'm trying out a new pattern, which is that the parsed object carries -around the ParseOptions it was created with, which should make some -testing a bit easier. - -I'm also not implementing the "config block" pattern in use for -Documents, because I think the UX is weird and I'm hoping to change -everything to use kwargs in a 2.0 release, anyway. ---- - ext/nokogiri/xml_relax_ng.c | 39 ++++++++++++++++++-------- - ext/nokogiri/xml_schema.c | 46 +++++++++++++++++++++++-------- - lib/nokogiri/xml/parse_options.rb | 2 ++ - lib/nokogiri/xml/relax_ng.rb | 4 +-- - lib/nokogiri/xml/schema.rb | 10 ++++--- - 5 files changed, 72 insertions(+), 29 deletions(-) - -diff --git a/ext/nokogiri/xml_relax_ng.c b/ext/nokogiri/xml_relax_ng.c -index e17b11a..f361d27 100644 ---- a/ext/nokogiri/xml_relax_ng.c -+++ b/ext/nokogiri/xml_relax_ng.c -@@ -53,16 +53,24 @@ static VALUE validate_document(VALUE self, VALUE document) - * - * Create a new RelaxNG from the contents of +string+ - */ --static VALUE read_memory(VALUE klass, VALUE content) -+static VALUE read_memory(int argc, VALUE *argv, VALUE klass) - { -- xmlRelaxNGParserCtxtPtr ctx = xmlRelaxNGNewMemParserCtxt( -- (const char *)StringValuePtr(content), -- (int)RSTRING_LEN(content) -- ); -+ VALUE content; -+ VALUE parse_options; -+ xmlRelaxNGParserCtxtPtr ctx; - xmlRelaxNGPtr schema; -- VALUE errors = rb_ary_new(); -+ VALUE errors; - VALUE rb_schema; -+ int scanned_args = 0; -+ -+ scanned_args = rb_scan_args(argc, argv, "11", &content, &parse_options); -+ if (scanned_args == 1) { -+ parse_options = rb_const_get(rb_const_get(mNokogiriXml, rb_intern("ParseOptions")), rb_intern("DEFAULT_SCHEMA")); -+ } - -+ ctx = xmlRelaxNGNewMemParserCtxt((const char *)StringValuePtr(content), (int)RSTRING_LEN(content)); -+ -+ errors = rb_ary_new(); - xmlSetStructuredErrorFunc((void *)errors, Nokogiri_error_array_pusher); - - #ifdef HAVE_XMLRELAXNGSETPARSERSTRUCTUREDERRORS -@@ -90,6 +98,7 @@ static VALUE read_memory(VALUE klass, VALUE content) - - rb_schema = Data_Wrap_Struct(klass, 0, dealloc, schema); - rb_iv_set(rb_schema, "@errors", errors); -+ rb_iv_set(rb_schema, "@parse_options", parse_options); - - return rb_schema; - } -@@ -100,18 +109,25 @@ static VALUE read_memory(VALUE klass, VALUE content) - * - * Create a new RelaxNG schema from the Nokogiri::XML::Document +doc+ - */ --static VALUE from_document(VALUE klass, VALUE document) -+static VALUE from_document(int argc, VALUE *argv, VALUE klass) - { -+ VALUE document; -+ VALUE parse_options; - xmlDocPtr doc; - xmlRelaxNGParserCtxtPtr ctx; - xmlRelaxNGPtr schema; - VALUE errors; - VALUE rb_schema; -+ int scanned_args = 0; -+ -+ scanned_args = rb_scan_args(argc, argv, "11", &document, &parse_options); - - Data_Get_Struct(document, xmlDoc, doc); -+ doc = doc->doc; /* In case someone passes us a node. ugh. */ - -- /* In case someone passes us a node. ugh. */ -- doc = doc->doc; -+ if (scanned_args == 1) { -+ parse_options = rb_const_get(rb_const_get(mNokogiriXml, rb_intern("ParseOptions")), rb_intern("DEFAULT_SCHEMA")); -+ } - - ctx = xmlRelaxNGNewDocParserCtxt(doc); - -@@ -142,6 +158,7 @@ static VALUE from_document(VALUE klass, VALUE document) - - rb_schema = Data_Wrap_Struct(klass, 0, dealloc, schema); - rb_iv_set(rb_schema, "@errors", errors); -+ rb_iv_set(rb_schema, "@parse_options", parse_options); - - return rb_schema; - } -@@ -155,7 +172,7 @@ void init_xml_relax_ng() - - cNokogiriXmlRelaxNG = klass; - -- rb_define_singleton_method(klass, "read_memory", read_memory, 1); -- rb_define_singleton_method(klass, "from_document", from_document, 1); -+ rb_define_singleton_method(klass, "read_memory", read_memory, -1); -+ rb_define_singleton_method(klass, "from_document", from_document, -1); - rb_define_private_method(klass, "validate_document", validate_document, 1); - } -diff --git a/ext/nokogiri/xml_schema.c b/ext/nokogiri/xml_schema.c -index 439f721..ea7c3d3 100644 ---- a/ext/nokogiri/xml_schema.c -+++ b/ext/nokogiri/xml_schema.c -@@ -93,15 +93,26 @@ static VALUE validate_file(VALUE self, VALUE rb_filename) - * - * Create a new Schema from the contents of +string+ - */ --static VALUE read_memory(VALUE klass, VALUE content) -+static VALUE read_memory(int argc, VALUE *argv, VALUE klass) - { -+ VALUE content; -+ VALUE parse_options; -+ int parse_options_int; -+ xmlSchemaParserCtxtPtr ctx; - xmlSchemaPtr schema; -- xmlSchemaParserCtxtPtr ctx = xmlSchemaNewMemParserCtxt( -- (const char *)StringValuePtr(content), -- (int)RSTRING_LEN(content) -- ); -+ VALUE errors; - VALUE rb_schema; -- VALUE errors = rb_ary_new(); -+ int scanned_args = 0; -+ -+ scanned_args = rb_scan_args(argc, argv, "11", &content, &parse_options); -+ if (scanned_args == 1) { -+ parse_options = rb_const_get(rb_const_get(mNokogiriXml, rb_intern("ParseOptions")), rb_intern("DEFAULT_SCHEMA")); -+ } -+ parse_options_int = (int)NUM2INT(rb_funcall(parse_options, rb_intern("to_i"), 0)); -+ -+ ctx = xmlSchemaNewMemParserCtxt((const char *)StringValuePtr(content), (int)RSTRING_LEN(content)); -+ -+ errors = rb_ary_new(); - xmlSetStructuredErrorFunc((void *)errors, Nokogiri_error_array_pusher); - - #ifdef HAVE_XMLSCHEMASETPARSERSTRUCTUREDERRORS -@@ -109,7 +120,7 @@ static VALUE read_memory(VALUE klass, VALUE content) - ctx, - Nokogiri_error_array_pusher, - (void *)errors -- ); -+ ); - #endif - - schema = xmlSchemaParse(ctx); -@@ -129,6 +140,7 @@ static VALUE read_memory(VALUE klass, VALUE content) - - rb_schema = Data_Wrap_Struct(klass, 0, dealloc, schema); - rb_iv_set(rb_schema, "@errors", errors); -+ rb_iv_set(rb_schema, "@parse_options", parse_options); - - return rb_schema; - } -@@ -164,18 +176,27 @@ static int has_blank_nodes_p(VALUE cache) - * - * Create a new Schema from the Nokogiri::XML::Document +doc+ - */ --static VALUE from_document(VALUE klass, VALUE document) -+static VALUE from_document(int argc, VALUE *argv, VALUE klass) - { -+ VALUE document; -+ VALUE parse_options; -+ int parse_options_int; - xmlDocPtr doc; - xmlSchemaParserCtxtPtr ctx; - xmlSchemaPtr schema; - VALUE errors; - VALUE rb_schema; -+ int scanned_args = 0; -+ -+ scanned_args = rb_scan_args(argc, argv, "11", &document, &parse_options); - - Data_Get_Struct(document, xmlDoc, doc); -+ doc = doc->doc; /* In case someone passes us a node. ugh. */ - -- /* In case someone passes us a node. ugh. */ -- doc = doc->doc; -+ if (scanned_args == 1) { -+ parse_options = rb_const_get(rb_const_get(mNokogiriXml, rb_intern("ParseOptions")), rb_intern("DEFAULT_SCHEMA")); -+ } -+ parse_options_int = (int)NUM2INT(rb_funcall(parse_options, rb_intern("to_i"), 0)); - - if (has_blank_nodes_p(DOC_NODE_CACHE(doc))) { - rb_raise(rb_eArgError, "Creating a schema from a document that has blank nodes exposed to Ruby is dangerous"); -@@ -211,6 +232,7 @@ static VALUE from_document(VALUE klass, VALUE document) - - rb_schema = Data_Wrap_Struct(klass, 0, dealloc, schema); - rb_iv_set(rb_schema, "@errors", errors); -+ rb_iv_set(rb_schema, "@parse_options", parse_options); - - return rb_schema; - -@@ -226,8 +248,8 @@ void init_xml_schema() - - cNokogiriXmlSchema = klass; - -- rb_define_singleton_method(klass, "read_memory", read_memory, 1); -- rb_define_singleton_method(klass, "from_document", from_document, 1); -+ rb_define_singleton_method(klass, "read_memory", read_memory, -1); -+ rb_define_singleton_method(klass, "from_document", from_document, -1); - - rb_define_private_method(klass, "validate_document", validate_document, 1); - rb_define_private_method(klass, "validate_file", validate_file, 1); -diff --git a/lib/nokogiri/xml/parse_options.rb b/lib/nokogiri/xml/parse_options.rb -index 8969578..c6d3d1c 100644 ---- a/lib/nokogiri/xml/parse_options.rb -+++ b/lib/nokogiri/xml/parse_options.rb -@@ -72,6 +72,8 @@ module Nokogiri - DEFAULT_XML = RECOVER | NONET - # the default options used for parsing HTML documents - DEFAULT_HTML = RECOVER | NOERROR | NOWARNING | NONET -+ # the default options used for parsing XML schemas -+ DEFAULT_SCHEMA = NONET - - attr_accessor :options - def initialize options = STRICT -diff --git a/lib/nokogiri/xml/relax_ng.rb b/lib/nokogiri/xml/relax_ng.rb -index 5a645a4..79bc30c 100644 ---- a/lib/nokogiri/xml/relax_ng.rb -+++ b/lib/nokogiri/xml/relax_ng.rb -@@ -4,8 +4,8 @@ module Nokogiri - ### - # Create a new Nokogiri::XML::RelaxNG document from +string_or_io+. - # See Nokogiri::XML::RelaxNG for an example. -- def RelaxNG string_or_io -- RelaxNG.new(string_or_io) -+ def RelaxNG(string_or_io, options = ParseOptions::DEFAULT_SCHEMA) -+ RelaxNG.new(string_or_io, options) - end - end - -diff --git a/lib/nokogiri/xml/schema.rb b/lib/nokogiri/xml/schema.rb -index 65a7bcd..a88f69c 100644 ---- a/lib/nokogiri/xml/schema.rb -+++ b/lib/nokogiri/xml/schema.rb -@@ -4,8 +4,8 @@ module Nokogiri - ### - # Create a new Nokogiri::XML::Schema object using a +string_or_io+ - # object. -- def Schema string_or_io -- Schema.new(string_or_io) -+ def Schema(string_or_io, options = ParseOptions::DEFAULT_SCHEMA) -+ Schema.new(string_or_io, options) - end - end - -@@ -29,12 +29,14 @@ module Nokogiri - class Schema - # Errors while parsing the schema file - attr_accessor :errors -+ # The Nokogiri::XML::ParseOptions used to parse the schema -+ attr_accessor :parse_options - - ### - # Create a new Nokogiri::XML::Schema object using a +string_or_io+ - # object. -- def self.new string_or_io -- from_document Nokogiri::XML(string_or_io) -+ def self.new string_or_io, options = ParseOptions::DEFAULT_SCHEMA -+ from_document(Nokogiri::XML(string_or_io), options) - end - - ### --- -2.23.0 - diff --git a/CVE-2021-41098-1.patch b/CVE-2021-41098-1.patch deleted file mode 100644 index e9fa4efdae7d326b4bad9bec7334088f2a8ccb7c..0000000000000000000000000000000000000000 --- a/CVE-2021-41098-1.patch +++ /dev/null @@ -1,684 +0,0 @@ -From 412f4e3a396dd36677ca202df96aa36656f9c800 Mon Sep 17 00:00:00 2001 -From: Mike Dalessio -Date: Fri, 24 Sep 2021 14:13:39 -0400 -Subject: [PATCH] refactor(jruby): handle errors more consistently - -NokogiriErrorHandler stores RubyException but also accepts (and -type-converts) Exception and RaiseException. - -NokgiriHandler uses NokogiriErrorHandler under the hood. - -NokogiriErrorHandler classes use addError consistently everywhere. ---- - ext/java/nokogiri/XmlSaxParserContext.java | 106 +++++------------- - ext/java/nokogiri/XmlSaxPushParser.java | 42 +++---- - .../internals/NokogiriEntityResolver.java | 2 +- - .../internals/NokogiriErrorHandler.java | 37 ++++-- - .../nokogiri/internals/NokogiriHandler.java | 26 +---- - .../NokogiriNonStrictErrorHandler.java | 17 +-- - ...okogiriNonStrictErrorHandler4NekoHtml.java | 18 +-- - .../internals/NokogiriStrictErrorHandler.java | 13 ++- - .../internals/XmlDomParserContext.java | 27 ++--- - 9 files changed, 115 insertions(+), 173 deletions(-) - -diff --git a/ext/java/nokogiri/XmlSaxParserContext.java b/ext/java/nokogiri/XmlSaxParserContext.java -index 5537619..5727a10 100644 ---- a/ext/java/nokogiri/XmlSaxParserContext.java -+++ b/ext/java/nokogiri/XmlSaxParserContext.java -@@ -32,33 +32,23 @@ - - package nokogiri; - --import static org.jruby.runtime.Helpers.invoke; -- - import java.io.IOException; - import java.io.InputStream; - --import nokogiri.internals.NokogiriHandler; --import nokogiri.internals.NokogiriHelpers; --import nokogiri.internals.ParserContext; --import nokogiri.internals.XmlSaxParser; -+import static org.jruby.runtime.Helpers.invoke; - -+import nokogiri.internals.*; - import org.apache.xerces.parsers.AbstractSAXParser; - import org.jruby.Ruby; - import org.jruby.RubyClass; - import org.jruby.RubyFixnum; --import org.jruby.RubyModule; --import org.jruby.RubyObjectAdapter; - import org.jruby.anno.JRubyClass; - import org.jruby.anno.JRubyMethod; - import org.jruby.exceptions.RaiseException; --import org.jruby.javasupport.JavaEmbedUtils; -+import org.jruby.runtime.Helpers; - import org.jruby.runtime.ThreadContext; - import org.jruby.runtime.builtin.IRubyObject; --import org.xml.sax.ContentHandler; --import org.xml.sax.ErrorHandler; - import org.xml.sax.SAXException; --import org.xml.sax.SAXNotRecognizedException; --import org.xml.sax.SAXNotSupportedException; - import org.xml.sax.SAXParseException; - - /** -@@ -82,6 +72,7 @@ public class XmlSaxParserContext extends ParserContext { - protected AbstractSAXParser parser; - - protected NokogiriHandler handler; -+ protected NokogiriErrorHandler errorHandler; - private boolean replaceEntities = true; - private boolean recovery = false; - -@@ -179,24 +170,11 @@ public class XmlSaxParserContext extends ParserContext { - return (XmlSaxParserContext) NokogiriService.XML_SAXPARSER_CONTEXT_ALLOCATOR.allocate(runtime, klazz); - } - -- /** -- * Set a property of the underlying parser. -- */ -- protected void setProperty(String key, Object val) -- throws SAXNotRecognizedException, SAXNotSupportedException { -- parser.setProperty(key, val); -- } -- -- protected void setContentHandler(ContentHandler handler) { -- parser.setContentHandler(handler); -- } -- -- protected void setErrorHandler(ErrorHandler handler) { -- parser.setErrorHandler(handler); -- } -- - public final NokogiriHandler getNokogiriHandler() { return handler; } - -+ public final NokogiriErrorHandler -+ getNokogiriErrorHandler() { return errorHandler; } -+ - /** - * Perform any initialization prior to parsing with the handler - * handlerRuby. Convenience hook for subclasses. -@@ -221,6 +199,17 @@ public class XmlSaxParserContext extends ParserContext { - parser.parse(getInputSource()); - } - -+ protected static Options -+ defaultParseOptions(ThreadContext context) -+ { -+ return new ParserContext.Options( -+ RubyFixnum.fix2long(Helpers.invoke(context, -+ ((RubyClass)context.getRuntime().getClassFromPath("Nokogiri::XML::ParseOptions")) -+ .getConstant("DEFAULT_XML"), -+ "to_i")) -+ ); -+ } -+ - @JRubyMethod - public IRubyObject parse_with(ThreadContext context, IRubyObject handlerRuby) { - final Ruby runtime = context.getRuntime(); -@@ -229,14 +218,18 @@ public class XmlSaxParserContext extends ParserContext { - throw runtime.newArgumentError("argument must respond_to document"); - } - -- NokogiriHandler handler = this.handler = new NokogiriHandler(runtime, handlerRuby); -- preParse(runtime, handlerRuby, handler); -+ /* TODO: how should we pass in parse options? */ -+ ParserContext.Options options = defaultParseOptions(context); -+ -+ errorHandler = new NokogiriStrictErrorHandler(runtime, options.noError, options.noWarning); -+ handler = new NokogiriHandler(runtime, handlerRuby, errorHandler); - -- setContentHandler(handler); -- setErrorHandler(handler); -+ preParse(runtime, handlerRuby, handler); -+ parser.setContentHandler(handler); -+ parser.setErrorHandler(handler); - - try{ -- setProperty("http://xml.org/sax/properties/lexical-handler", handler); -+ parser.setProperty("http://xml.org/sax/properties/lexical-handler", handler); - } - catch (Exception ex) { - throw runtime.newRuntimeError("Problem while creating XML SAX Parser: " + ex.toString()); -@@ -269,8 +262,6 @@ public class XmlSaxParserContext extends ParserContext { - - postParse(runtime, handlerRuby, handler); - -- //maybeTrimLeadingAndTrailingWhitespace(context, handlerRuby); -- - return runtime.getNil(); - } - -@@ -310,48 +301,6 @@ public class XmlSaxParserContext extends ParserContext { - return context.runtime.newBoolean(recovery); - } - -- /** -- * If the handler's document is a FragmentHandler, attempt to trim -- * leading and trailing whitespace. -- * -- * This is a bit hackish and depends heavily on the internals of -- * FragmentHandler. -- */ -- protected void maybeTrimLeadingAndTrailingWhitespace(ThreadContext context, IRubyObject parser) { -- RubyObjectAdapter adapter = JavaEmbedUtils.newObjectAdapter(); -- RubyModule mod = context.getRuntime().getClassFromPath("Nokogiri::XML::FragmentHandler"); -- -- IRubyObject handler = adapter.getInstanceVariable(parser, "@document"); -- if (handler == null || handler.isNil() || !adapter.isKindOf(handler, mod)) -- return; -- IRubyObject stack = adapter.getInstanceVariable(handler, "@stack"); -- if (stack == null || stack.isNil()) -- return; -- // doc is finally a DocumentFragment whose nodes we can check -- IRubyObject doc = adapter.callMethod(stack, "first"); -- if (doc == null || doc.isNil()) -- return; -- -- IRubyObject children; -- -- for (;;) { -- children = adapter.callMethod(doc, "children"); -- IRubyObject first = adapter.callMethod(children, "first"); -- if (NokogiriHelpers.isBlank(first)) adapter.callMethod(first, "unlink"); -- else break; -- } -- -- for (;;) { -- children = adapter.callMethod(doc, "children"); -- IRubyObject last = adapter.callMethod(children, "last"); -- if (NokogiriHelpers.isBlank(last)) adapter.callMethod(last, "unlink"); -- else break; -- } -- -- // While we have a document, normalize it. -- ((XmlNode) doc).normalize(); -- } -- - @JRubyMethod(name="column") - public IRubyObject column(ThreadContext context) { - final Integer number = handler.getColumn(); -@@ -365,5 +314,4 @@ public class XmlSaxParserContext extends ParserContext { - if (number == null) return context.getRuntime().getNil(); - return RubyFixnum.newFixnum(context.getRuntime(), number.longValue()); - } -- - } -diff --git a/ext/java/nokogiri/XmlSaxPushParser.java b/ext/java/nokogiri/XmlSaxPushParser.java -index 8e65b92..b1b65a9 100644 ---- a/ext/java/nokogiri/XmlSaxPushParser.java -+++ b/ext/java/nokogiri/XmlSaxPushParser.java -@@ -32,21 +32,10 @@ - - package nokogiri; - --import static nokogiri.internals.NokogiriHelpers.getNokogiriClass; --import static org.jruby.runtime.Helpers.invoke; -- --import java.io.ByteArrayInputStream; --import java.io.IOException; --import java.io.InputStream; --import java.util.concurrent.ExecutionException; --import java.util.concurrent.ExecutorService; --import java.util.concurrent.Executors; --import java.util.concurrent.Future; --import java.util.concurrent.FutureTask; --import java.util.concurrent.ThreadFactory; -- -+import nokogiri.internals.*; - import org.jruby.Ruby; - import org.jruby.RubyClass; -+import org.jruby.RubyException; - import org.jruby.RubyObject; - import org.jruby.anno.JRubyClass; - import org.jruby.anno.JRubyMethod; -@@ -54,11 +43,14 @@ import org.jruby.exceptions.RaiseException; - import org.jruby.runtime.ThreadContext; - import org.jruby.runtime.builtin.IRubyObject; - --import nokogiri.internals.ClosedStreamException; --import nokogiri.internals.NokogiriBlockingQueueInputStream; --import nokogiri.internals.NokogiriHandler; --import nokogiri.internals.NokogiriHelpers; --import nokogiri.internals.ParserContext; -+import java.io.ByteArrayInputStream; -+import java.io.IOException; -+import java.io.InputStream; -+import java.util.List; -+import java.util.concurrent.*; -+ -+import static nokogiri.internals.NokogiriHelpers.getNokogiriClass; -+import static org.jruby.runtime.Helpers.invoke; - - /** - * Class for Nokogiri::XML::SAX::PushParser -@@ -173,7 +165,8 @@ public class XmlSaxPushParser extends RubyObject { - - if (!options.recover && parserTask.getErrorCount() > errorCount0) { - terminateTask(context.runtime); -- throw ex = parserTask.getLastError(); -+ ex = parserTask.getLastError().toThrowable(); -+ throw ex; - } - - return this; -@@ -273,14 +266,13 @@ public class XmlSaxPushParser extends RubyObject { - - synchronized final int getErrorCount() { - // check for null because thread may not have started yet -- if (parser.getNokogiriHandler() == null) return 0; -- return parser.getNokogiriHandler().getErrorCount(); -+ if (parser.getNokogiriErrorHandler() == null) { return 0; } -+ return parser.getNokogiriErrorHandler().getErrors().size(); - } - -- synchronized final RaiseException getLastError() { -- return parser.getNokogiriHandler().getLastError(); -+ synchronized final RubyException getLastError() { -+ List errors = parser.getNokogiriErrorHandler().getErrors(); -+ return errors.get(errors.size() - 1); - } -- - } -- - } -diff --git a/ext/java/nokogiri/internals/NokogiriEntityResolver.java b/ext/java/nokogiri/internals/NokogiriEntityResolver.java -index d97da66..48942d0 100644 ---- a/ext/java/nokogiri/internals/NokogiriEntityResolver.java -+++ b/ext/java/nokogiri/internals/NokogiriEntityResolver.java -@@ -68,7 +68,7 @@ public class NokogiriEntityResolver implements EntityResolver2 { - } - - private void addError(String errorMessage) { -- if (handler != null) handler.errors.add(new Exception(errorMessage)); -+ if (handler != null) { handler.addError(new Exception(errorMessage)); } - } - - /** -diff --git a/ext/java/nokogiri/internals/NokogiriErrorHandler.java b/ext/java/nokogiri/internals/NokogiriErrorHandler.java -index 7980107..13b1725 100644 ---- a/ext/java/nokogiri/internals/NokogiriErrorHandler.java -+++ b/ext/java/nokogiri/internals/NokogiriErrorHandler.java -@@ -32,12 +32,16 @@ - - package nokogiri.internals; - --import java.util.ArrayList; --import java.util.List; -- -+import nokogiri.XmlSyntaxError; - import org.apache.xerces.xni.parser.XMLErrorHandler; -+import org.jruby.Ruby; -+import org.jruby.RubyException; -+import org.jruby.exceptions.RaiseException; - import org.xml.sax.ErrorHandler; - -+import java.util.ArrayList; -+import java.util.List; -+ - /** - * Super class of error handlers. - * -@@ -48,19 +52,36 @@ import org.xml.sax.ErrorHandler; - * @author Yoko Harada - */ - public abstract class NokogiriErrorHandler implements ErrorHandler, XMLErrorHandler { -- protected final List errors; -+ private final Ruby runtime; -+ protected final List errors; - protected boolean noerror; - protected boolean nowarning; - -- public NokogiriErrorHandler(boolean noerror, boolean nowarning) { -- this.errors = new ArrayList(4); -+ public NokogiriErrorHandler(Ruby runtime, boolean noerror, boolean nowarning) -+ this.runtime = runtime; -+ this.errors = new ArrayList(4); - this.noerror = noerror; - this.nowarning = nowarning; - } - -- List getErrors() { return errors; } -+ public List getErrors() { return errors; } - -- public void addError(Exception ex) { errors.add(ex); } -+ public void addError(Exception ex) -+ { -+ addError(XmlSyntaxError.createXMLSyntaxError(runtime, ex)); -+ } -+ -+ public void -+ addError(RubyException ex) -+ { -+ errors.add(ex); -+ } -+ -+ public void -+ addError(RaiseException ex) -+ { -+ addError(ex.getException()); -+ } - - protected boolean usesNekoHtml(String domain) { - return "http://cyberneko.org/html".equals(domain); -diff --git a/ext/java/nokogiri/internals/NokogiriHandler.java b/ext/java/nokogiri/internals/NokogiriHandler.java -index 5e34be1..2da4011 100644 ---- a/ext/java/nokogiri/internals/NokogiriHandler.java -+++ b/ext/java/nokogiri/internals/NokogiriHandler.java -@@ -69,23 +69,17 @@ public class NokogiriHandler extends DefaultHandler2 implements XmlDeclHandler { - private final Ruby runtime; - private final RubyClass attrClass; - private final IRubyObject object; -- -- /** -- * Stores parse errors with the most-recent error last. -- * -- * TODO: should these be stored in the document 'errors' array? -- * Currently only string messages are stored there. -- */ -- private final LinkedList errors = new LinkedList(); -+ private NokogiriErrorHandler errorHandler; - - private Locator locator; - private boolean needEmptyAttrCheck; - -- public NokogiriHandler(Ruby runtime, IRubyObject object) { -+ public NokogiriHandler(Ruby runtime, IRubyObject object, NokogiriErrorHandler errorHandler) { - assert object != null; - this.runtime = runtime; - this.attrClass = (RubyClass) runtime.getClassFromPath("Nokogiri::XML::SAX::Parser::Attribute"); - this.object = object; -+ this.errorHandler = errorHandler; - charactersBuilder = new StringBuilder(); - String objectName = object.getMetaClass().getName(); - if ("Nokogiri::HTML::SAX::Parser".equals(objectName)) needEmptyAttrCheck = true; -@@ -249,9 +243,9 @@ public class NokogiriHandler extends DefaultHandler2 implements XmlDeclHandler { - try { - final String msg = ex.getMessage(); - call("error", runtime.newString(msg == null ? "" : msg)); -- addError(new RaiseException(XmlSyntaxError.createError(runtime, ex), true)); -+ errorHandler.addError(ex); - } catch( RaiseException e) { -- addError(e); -+ errorHandler.addError(e); - throw e; - } - } -@@ -272,16 +266,8 @@ public class NokogiriHandler extends DefaultHandler2 implements XmlDeclHandler { - call("warning", runtime.newString(msg == null ? "" : msg)); - } - -- protected synchronized void addError(RaiseException e) { -- errors.add(e); -- } -- - public synchronized int getErrorCount() { -- return errors.size(); -- } -- -- public synchronized RaiseException getLastError() { -- return errors.getLast(); -+ return errorHandler.getErrors().size(); - } - - private void call(String methodName) { -diff --git a/ext/java/nokogiri/internals/NokogiriNonStrictErrorHandler.java b/ext/java/nokogiri/internals/NokogiriNonStrictErrorHandler.java -index 15b622c..f49e13d 100644 ---- a/ext/java/nokogiri/internals/NokogiriNonStrictErrorHandler.java -+++ b/ext/java/nokogiri/internals/NokogiriNonStrictErrorHandler.java -@@ -33,6 +33,7 @@ - package nokogiri.internals; - - import org.apache.xerces.xni.parser.XMLParseException; -+import org.jruby.Ruby; - import org.xml.sax.SAXException; - import org.xml.sax.SAXParseException; - -@@ -43,16 +44,16 @@ import org.xml.sax.SAXParseException; - * @author Yoko Harada - */ - public class NokogiriNonStrictErrorHandler extends NokogiriErrorHandler{ -- public NokogiriNonStrictErrorHandler(boolean noerror, boolean nowarning) { -- super(noerror, nowarning); -+ public NokogiriNonStrictErrorHandler(Ruby runtime, boolean noerror, boolean nowarning) { -+ super(runtime, noerror, nowarning); - } - - public void warning(SAXParseException ex) throws SAXException { -- errors.add(ex); -+ addError(ex); - } - - public void error(SAXParseException ex) throws SAXException { -- errors.add(ex); -+ addError(ex); - } - - public void fatalError(SAXParseException ex) throws SAXException { -@@ -61,7 +62,7 @@ public class NokogiriNonStrictErrorHandler extends NokogiriErrorHandler{ - // found in the prolog, instead it will keep calling this method and we'll - // keep inserting the error in the document errors array until we run - // out of memory -- errors.add(ex); -+ addError(ex); - String message = ex.getMessage(); - - // The problem with Xerces is that some errors will cause the -@@ -74,15 +75,15 @@ public class NokogiriNonStrictErrorHandler extends NokogiriErrorHandler{ - } - - public void error(String domain, String key, XMLParseException e) { -- errors.add(e); -+ addError(e); - } - - public void fatalError(String domain, String key, XMLParseException e) { -- errors.add(e); -+ addError(e); - } - - public void warning(String domain, String key, XMLParseException e) { -- errors.add(e); -+ addError(e); - } - - /* -diff --git a/ext/java/nokogiri/internals/NokogiriNonStrictErrorHandler4NekoHtml.java b/ext/java/nokogiri/internals/NokogiriNonStrictErrorHandler4NekoHtml.java -index 011af24..a2c6b33 100644 ---- a/ext/java/nokogiri/internals/NokogiriNonStrictErrorHandler4NekoHtml.java -+++ b/ext/java/nokogiri/internals/NokogiriNonStrictErrorHandler4NekoHtml.java -@@ -33,6 +33,7 @@ - package nokogiri.internals; - - import org.apache.xerces.xni.parser.XMLParseException; -+import org.jruby.Ruby; - import org.xml.sax.SAXException; - import org.xml.sax.SAXParseException; - -@@ -50,12 +51,13 @@ import org.xml.sax.SAXParseException; - */ - public class NokogiriNonStrictErrorHandler4NekoHtml extends NokogiriErrorHandler { - -- public NokogiriNonStrictErrorHandler4NekoHtml(boolean nowarning) { -- super(false, nowarning); -+ public NokogiriNonStrictErrorHandler4NekoHtml(Ruby runtime, boolean nowarning) { -+ super(runtime, false, nowarning); - } - - public NokogiriNonStrictErrorHandler4NekoHtml(boolean noerror, boolean nowarning) { -- super(noerror, nowarning); -+ public NokogiriNonStrictErrorHandler4NekoHtml(Ruby runtime, boolean noerror, boolean nowarning) { -+ super(runtime, noerror, nowarning); - } - - public void warning(SAXParseException ex) throws SAXException { -@@ -63,11 +65,11 @@ public class NokogiriNonStrictErrorHandler4NekoHtml extends NokogiriErrorHandler - } - - public void error(SAXParseException ex) throws SAXException { -- errors.add(ex); -+ addError(ex); - } - - public void fatalError(SAXParseException ex) throws SAXException { -- errors.add(ex); -+ addError(ex); - } - - /** -@@ -83,7 +85,7 @@ public class NokogiriNonStrictErrorHandler4NekoHtml extends NokogiriErrorHandler - * @param e Exception. - */ - public void error(String domain, String key, XMLParseException e) { -- errors.add(e); -+ addError(e); - } - - /** -@@ -99,7 +101,7 @@ public class NokogiriNonStrictErrorHandler4NekoHtml extends NokogiriErrorHandler - * @param e Exception. - */ - public void fatalError(String domain, String key, XMLParseException e) { -- errors.add(e); -+ addError(e); - } - - /** -@@ -115,7 +117,7 @@ public class NokogiriNonStrictErrorHandler4NekoHtml extends NokogiriErrorHandler - * @param e Exception. - */ - public void warning(String domain, String key, XMLParseException e) { -- errors.add(e); -+ addError(e); - } - - } -diff --git a/ext/java/nokogiri/internals/NokogiriStrictErrorHandler.java b/ext/java/nokogiri/internals/NokogiriStrictErrorHandler.java -index 10315fa..fbf9787 100644 ---- a/ext/java/nokogiri/internals/NokogiriStrictErrorHandler.java -+++ b/ext/java/nokogiri/internals/NokogiriStrictErrorHandler.java -@@ -33,6 +33,7 @@ - package nokogiri.internals; - - import org.apache.xerces.xni.parser.XMLParseException; -+import org.jruby.Ruby; - import org.xml.sax.SAXException; - import org.xml.sax.SAXParseException; - -@@ -44,18 +45,18 @@ import org.xml.sax.SAXParseException; - * @author Yoko Harada - */ - public class NokogiriStrictErrorHandler extends NokogiriErrorHandler { -- public NokogiriStrictErrorHandler(boolean noerror, boolean nowarning) { -- super(noerror, nowarning); -+ public NokogiriStrictErrorHandler(Ruby runtime, boolean noerror, boolean nowarning) { -+ super(runtime, noerror, nowarning); - } - - public void warning(SAXParseException spex) throws SAXException { - if (!nowarning) throw spex; -- else errors.add(spex); -+ else { addError(spex); } - } - - public void error(SAXParseException spex) throws SAXException { - if (!noerror) throw spex; -- else errors.add(spex); -+ else { addError(spex); } - } - - public void fatalError(SAXParseException spex) throws SAXException { -@@ -64,7 +65,7 @@ public class NokogiriStrictErrorHandler extends NokogiriErrorHandler { - - public void error(String domain, String key, XMLParseException e) throws XMLParseException { - if (!noerror) throw e; -- else errors.add(e); -+ else { addError(e); } - } - - public void fatalError(String domain, String key, XMLParseException e) throws XMLParseException { -@@ -73,6 +74,6 @@ public class NokogiriStrictErrorHandler extends NokogiriErrorHandler { - - public void warning(String domain, String key, XMLParseException e) throws XMLParseException { - if (!nowarning) throw e; -- if (!usesNekoHtml(domain)) errors.add(e); -+ if (!usesNekoHtml(domain)) { addError(e); } - } - } -diff --git a/ext/java/nokogiri/internals/XmlDomParserContext.java b/ext/java/nokogiri/internals/XmlDomParserContext.java -index 89af2bc..839399b 100644 ---- a/ext/java/nokogiri/internals/XmlDomParserContext.java -+++ b/ext/java/nokogiri/internals/XmlDomParserContext.java -@@ -32,23 +32,17 @@ - - package nokogiri.internals; - --import static nokogiri.internals.NokogiriHelpers.getNokogiriClass; --import static nokogiri.internals.NokogiriHelpers.isBlank; -- - import java.io.IOException; - import java.util.ArrayList; - import java.util.List; - --import nokogiri.NokogiriService; -+import static nokogiri.internals.NokogiriHelpers.isBlank; -+ - import nokogiri.XmlDocument; - import nokogiri.XmlDtd; - import nokogiri.XmlSyntaxError; -- - import org.apache.xerces.parsers.DOMParser; --import org.jruby.Ruby; --import org.jruby.RubyArray; --import org.jruby.RubyClass; --import org.jruby.RubyFixnum; -+import org.jruby.*; - import org.jruby.exceptions.RaiseException; - import org.jruby.runtime.ThreadContext; - import org.jruby.runtime.builtin.IRubyObject; -@@ -78,7 +72,6 @@ public class XmlDomParserContext extends ParserContext { - protected static final String FEATURE_NOT_EXPAND_ENTITY = - "http://apache.org/xml/features/dom/create-entity-ref-nodes"; - protected static final String FEATURE_VALIDATION = "http://xml.org/sax/features/validation"; -- private static final String XINCLUDE_FEATURE_ID = "http://apache.org/xml/features/xinclude"; - private static final String SECURITY_MANAGER = "http://apache.org/xml/properties/security-manager"; - - protected ParserContext.Options options; -@@ -96,15 +89,15 @@ public class XmlDomParserContext extends ParserContext { - this.options = new ParserContext.Options(RubyFixnum.fix2long(options)); - java_encoding = NokogiriHelpers.getValidEncoding(runtime, encoding); - ruby_encoding = encoding; -- initErrorHandler(); -+ initErrorHandler(runtime); - initParser(runtime); - } - -- protected void initErrorHandler() { -+ protected void initErrorHandler(Ruby runtime) { - if (options.recover) { -- errorHandler = new NokogiriNonStrictErrorHandler(options.noError, options.noWarning); -+ errorHandler = new NokogiriNonStrictErrorHandler(runtime, options.noError, options.noWarning); - } else { -- errorHandler = new NokogiriStrictErrorHandler(options.noError, options.noWarning); -+ errorHandler = new NokogiriStrictErrorHandler(runtime, options.noError, options.noWarning); - } - } - -@@ -176,12 +169,10 @@ public class XmlDomParserContext extends ParserContext { - - public static RubyArray mapErrors(ThreadContext context, NokogiriErrorHandler errorHandler) { - final Ruby runtime = context.runtime; -- final List errors = errorHandler.getErrors(); -+ final List errors = errorHandler.getErrors(); - final IRubyObject[] errorsAry = new IRubyObject[errors.size()]; - for (int i = 0; i < errors.size(); i++) { -- XmlSyntaxError xmlSyntaxError = XmlSyntaxError.createXMLSyntaxError(runtime); -- xmlSyntaxError.setException(errors.get(i)); -- errorsAry[i] = xmlSyntaxError; -+ errorsAry[i] = errors.get(i); - } - return runtime.newArrayNoCopy(errorsAry); - } --- -2.27.0 - diff --git a/CVE-2021-41098-2.patch b/CVE-2021-41098-2.patch deleted file mode 100644 index 9a582e85e82e8fecee7e8c45032ca75c779268b8..0000000000000000000000000000000000000000 --- a/CVE-2021-41098-2.patch +++ /dev/null @@ -1,28 +0,0 @@ -From 382860304b2efbf837cb3fcbbe806c81c27bf6b1 Mon Sep 17 00:00:00 2001 -From: Mike Dalessio -Date: Fri, 24 Sep 2021 14:15:26 -0400 -Subject: [PATCH] fix(jruby): SAX parser uses an entity resolver - -to avoid XXE injections. - -This behavior now matches the CRuby implementation. ---- - ext/java/nokogiri/XmlSaxParserContext.java | 1 + - test/xml/sax/test_parser.rb | 33 ++++++++++++++++++++++ - 2 files changed, 34 insertions(+) - -diff --git a/ext/java/nokogiri/XmlSaxParserContext.java b/ext/java/nokogiri/XmlSaxParserContext.java -index 5727a10..e614ce9 100644 ---- a/ext/java/nokogiri/XmlSaxParserContext.java -+++ b/ext/java/nokogiri/XmlSaxParserContext.java -@@ -227,6 +227,7 @@ public class XmlSaxParserContext extends ParserContext { - preParse(runtime, handlerRuby, handler); - parser.setContentHandler(handler); - parser.setErrorHandler(handler); -+ parser.setEntityResolver(new NokogiriEntityResolver(runtime, errorHandler, options)); - - try{ - parser.setProperty("http://xml.org/sax/properties/lexical-handler", handler); --- -2.27.0 - diff --git a/fix-canonicalize-already-defined-by-glibc.patch b/fix-canonicalize-already-defined-by-glibc.patch deleted file mode 100644 index c62626ef7313999b7dcb8bc75780b8d2b85f2904..0000000000000000000000000000000000000000 --- a/fix-canonicalize-already-defined-by-glibc.patch +++ /dev/null @@ -1,32 +0,0 @@ -From 7a74cdbe4538e964023e5a0fdca58d8af708b91e Mon Sep 17 00:00:00 2001 -From: Mike Dalessio -Date: Thu, 29 Oct 2020 11:50:11 -0400 -Subject: [PATCH 1/2] fix: avoid collision with glibc's canonicalize() method - -Closes #2105 ---- - ext/nokogiri/xml_document.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/ext/nokogiri/xml_document.c b/ext/nokogiri/xml_document.c -index 3a8ba06e3e..6c010b5438 100644 ---- a/ext/nokogiri/xml_document.c -+++ b/ext/nokogiri/xml_document.c -@@ -506,7 +506,7 @@ static int block_caller(void * ctx, xmlNodePtr _node, xmlNodePtr _parent) - * The block must return a non-nil, non-false value if the +obj+ passed in - * should be included in the canonicalized document. - */ --static VALUE canonicalize(int argc, VALUE* argv, VALUE self) -+static VALUE nokogiri_xml_document_canonicalize(int argc, VALUE* argv, VALUE self) - { - VALUE mode; - VALUE incl_ns; -@@ -587,7 +587,7 @@ void init_xml_document() - rb_define_method(klass, "encoding", encoding, 0); - rb_define_method(klass, "encoding=", set_encoding, 1); - rb_define_method(klass, "version", version, 0); -- rb_define_method(klass, "canonicalize", canonicalize, -1); -+ rb_define_method(klass, "canonicalize", nokogiri_xml_document_canonicalize, -1); - rb_define_method(klass, "dup", duplicate_document, -1); - rb_define_method(klass, "url", url, 0); - rb_define_method(klass, "create_entity", create_entity, -1); diff --git a/fix-test-node-fail.patch b/fix-test-node-fail.patch deleted file mode 100644 index 24ee5f1916b53705467dd0d990e913fcedf49b2c..0000000000000000000000000000000000000000 --- a/fix-test-node-fail.patch +++ /dev/null @@ -1,38 +0,0 @@ -From 462d84a3dee286c75ca3c9185b48f0f7827a9d5f Mon Sep 17 00:00:00 2001 -From: wk333 <13474090681@163.com> -Date: Thu, 6 Jan 2022 04:17:38 +0800 -Subject: [PATCH 1/1] fix test node fail - ---- - test/xml/test_node.rb | 15 --------------- - 1 file changed, 15 deletions(-) - -diff --git a/test/xml/test_node.rb b/test/xml/test_node.rb -index 4cd8292..707fa5a 100644 ---- a/test/xml/test_node.rb -+++ b/test/xml/test_node.rb -@@ -1193,21 +1193,6 @@ EOXML - assert_nil set[4].attributes['x'].namespace - end - -- if Nokogiri.uses_libxml? -- def test_namespace_without_an_href_on_html_node -- # because microsoft word's HTML formatting does this. ick. -- xml = Nokogiri::HTML.parse <<-EOF --
foo
-- EOF -- -- assert_not_nil(node = xml.at('p')) -- -- assert_equal 1, node.namespaces.keys.size -- assert node.namespaces.has_key?('xmlns:o') -- assert_nil node.namespaces['xmlns:o'] -- end -- end -- - def test_line - xml = Nokogiri::XML(<<-eoxml) - --- -2.27.0 - diff --git a/fix-test-push-parser-fail.patch b/fix-test-push-parser-fail.patch deleted file mode 100644 index 0e93b6222a1e9d940d34424a281eceb3d9b47108..0000000000000000000000000000000000000000 --- a/fix-test-push-parser-fail.patch +++ /dev/null @@ -1,33 +0,0 @@ -From ee33011cdcb3018314e4d23abbcbd17470a48290 Mon Sep 17 00:00:00 2001 -From: baizg1107 -Date: Thu, 9 Dec 2021 19:47:10 +0800 -Subject: [PATCH] fix test push parser fail - ---- - test/html/sax/test_push_parser.rb | 10 ---------- - 1 file changed, 10 deletions(-) - -diff --git a/test/html/sax/test_push_parser.rb b/test/html/sax/test_push_parser.rb -index a3939d0..9536114 100644 ---- a/test/html/sax/test_push_parser.rb -+++ b/test/html/sax/test_push_parser.rb -@@ -71,16 +71,6 @@ module Nokogiri - assert_equal 0, @parser.options - end - -- def test_broken_encoding -- skip("ultra hard to fix for pure Java version") if Nokogiri.jruby? -- @parser.options |= XML::ParseOptions::RECOVER -- # This is ISO_8859-1: -- @parser.<< "Gau\337" -- @parser.finish -- assert(@parser.document.errors.size >= 1) -- assert_equal "Gau\337", @parser.document.data.join -- assert_equal [["r"], ["body"], ["html"]], @parser.document.end_elements -- end - end - end - end --- -2.27.0 - diff --git a/nokogiri-1.10.5.gem b/nokogiri-1.13.1.gem similarity index 59% rename from nokogiri-1.10.5.gem rename to nokogiri-1.13.1.gem index fbbbb94a4f937d30fbf03889058df76e26b4a821..481da352f9e72c25c383e78a2ee94a0ea375903f 100644 Binary files a/nokogiri-1.10.5.gem and b/nokogiri-1.13.1.gem differ diff --git a/nokogiri-create-full-tarball.sh b/nokogiri-create-full-tarball.sh new file mode 100644 index 0000000000000000000000000000000000000000..d6fbd01524ff1619fa8ab9100ff8c9b10013c675 --- /dev/null +++ b/nokogiri-create-full-tarball.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +if [ $# -lt 2 ] +then + echo "$0 " + exit 1 +fi + +set -x +set -e + +CURRDIR=$(pwd) + +TMPDIRPATH=$(mktemp -d /var/tmp/$1-tar-XXXXXX) +pushd $TMPDIRPATH + +git clone https://github.com/sparklemotion/$1.git +pushd $1 +git reset --hard v$2 +popd + +ln -sf $1 $1-$2 +tar czf ${CURRDIR}/rubygem-$1-$2-full.tar.gz $1-$2/./ + +popd + +rm -rf $TMPDIRPATH diff --git a/rubygem-nokogiri-1.11.0.rc4-shutdown-libxml2-warning.patch b/rubygem-nokogiri-1.11.0.rc4-shutdown-libxml2-warning.patch new file mode 100644 index 0000000000000000000000000000000000000000..c1ed61c69bbdced956f020d61c53f78fe8fce7f5 --- /dev/null +++ b/rubygem-nokogiri-1.11.0.rc4-shutdown-libxml2-warning.patch @@ -0,0 +1,10 @@ +--- nokogiri-1.11.0.rc4/lib/nokogiri/version/info.rb.warn 2020-12-31 16:56:11.533949657 +0900 ++++ nokogiri-1.11.0.rc4/lib/nokogiri/version/info.rb 2020-12-31 16:59:38.576697147 +0900 +@@ -58,6 +58,7 @@ module Nokogiri + + def warnings + warnings = [] ++ return warnings + + if libxml2? + if compiled_libxml_version != loaded_libxml_version diff --git a/rubygem-nokogiri-1.13.1-full.tar.gz b/rubygem-nokogiri-1.13.1-full.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..776d80adb115f17c44a271826de87e8b9016a1d1 Binary files /dev/null and b/rubygem-nokogiri-1.13.1-full.tar.gz differ diff --git a/rubygem-nokogiri-1.6.6.4-shutdown-libxml2-warning.patch b/rubygem-nokogiri-1.6.6.4-shutdown-libxml2-warning.patch deleted file mode 100644 index add8fe8bf5cf030579681fa804cf421a6bfb6b53..0000000000000000000000000000000000000000 --- a/rubygem-nokogiri-1.6.6.4-shutdown-libxml2-warning.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- nokogiri-1.6.6.4/./lib/nokogiri/version.rb.nowarn 2015-11-20 05:50:37.000000000 +0900 -+++ nokogiri-1.6.6.4/./lib/nokogiri/version.rb 2015-12-11 14:32:04.151973080 +0900 -@@ -34,6 +34,7 @@ - end - - def warnings -+ return [] - return [] unless libxml2? - - if compiled_parser_version != loaded_parser_version diff --git a/rubygem-nokogiri.spec b/rubygem-nokogiri.spec index 724567ae17880fe2b6288abf462ac49a9717724f..0e00e5f1343bd0a6f3f56805572bccd365998ccf 100644 --- a/rubygem-nokogiri.spec +++ b/rubygem-nokogiri.spec @@ -1,4 +1,4 @@ -%global mainver 1.10.5 +%global mainver 1.13.1 %global mainrel 1 %global prerpmver %(echo "%{?prever}" | sed -e 's|\\.||g') %global gem_name nokogiri @@ -7,23 +7,19 @@ Summary: An HTML, XML, SAX, and Reader parser Name: rubygem-%{gem_name} Version: %{mainver} -Release: 5 -License: MIT +Release: 1 +License: MIT and ASL 2.0 URL: https://nokogiri.org Source0: https://rubygems.org/gems/%{gem_name}-%{mainver}%{?prever}.gem -Source1: https://github.com/sparklemotion/%{gem_name}/archive/v%{mainver}.tar.gz +Source1: rubygem-%{gem_name}-%{version}%{?prever}-full.tar.gz +Source2: rubygem-%{gem_name}-%{version}%{?prever}-full.tar.gz # Shut down libxml2 version unmatching warning -Patch0: %{name}-1.6.6.4-shutdown-libxml2-warning.patch -Patch1: CVE-2020-26247-pre.patch -Patch2: CVE-2020-26247.patch -Patch3: CVE-2021-41098-1.patch -Patch4: CVE-2021-41098-2.patch -Patch5: fix-test-push-parser-fail.patch -Patch6: fix-test-node-fail.patch -Patch7: fix-canonicalize-already-defined-by-glibc.patch +Patch0: %{name}-1.11.0.rc4-shutdown-libxml2-warning.patch BuildRequires: ruby(release) ruby(rubygems) rubygem(minitest) rubygems-devel Obsoletes: ruby-%{gem_name} <= 1.5.2-2 -BuildRequires: gcc rubygem(pkg-config) libxml2-devel libxslt-devel ruby-devel +BuildRequires: gcc libxml2-devel libxslt-devel ruby-devel glibc-all-langpacks rubygem(racc) +Requires: rubygem(racc) + %description Nokogiri parses and searches XML/HTML very quickly, and also has correctly implemented CSS3 selector support as well as XPath support. @@ -53,38 +49,35 @@ This package provides non-Gem support for %{gem_name}. %global version %{mainver}%{?prever} %prep -%setup -q -T -c -a 1 -TOPDIR=$(pwd) -mkdir tmpunpackdir -pushd tmpunpackdir -gem unpack %{SOURCE0} -cd %{gem_name}-%{version} +%setup -q -n %{gem_name}-%{version} -a 1 +mv ../%{gem_name}-%{version}.gemspec . %patch0 -p1 -%patch1 -p1 -%patch2 -p1 -%patch7 -p1 -#The file exists only in the source code directory,not in the GEM. -cd $TOPDIR/%{gem_name}-%{version} -%patch3 -p1 -%patch4 -p1 -%patch5 -p1 -%patch6 -p1 -cd - - -gem specification -l --ruby %{SOURCE0} > %{gem_name}.gemspec sed -i \ -e 's|, "ports/archives/[^"][^"]*"||g' \ -e 's|, "ports/patches/[^"][^"]*"||g' \ - %{gem_name}.gemspec -sed -i -e '\@mini_portile@d' %{gem_name}.gemspec -LANG=C.UTF-8 gem build %{gem_name}.gemspec -mv %{gem_name}-%{version}.gem $TOPDIR -popd -rm -rf tmpunpackdir + %{gem_name}-%{version}.gemspec +sed -i -e '\@mini_portile@d' %{gem_name}-%{version}.gemspec +sed -i \ + ext/nokogiri/extconf.rb \ + -e "s@^\(def process_recipe.*\)\$@\1 ; return true@" \ + -e "s@^\(append_cppflags\).*gumbo.*\$@\1(\"-I$(pwd)/gumbo-parser/src\")@" \ + -e "\@libs.*gumbo@s@File\.join.*@\"$(pwd)/gumbo-parser/src/libgumbo.a\"@" \ + -e "\@LIBPATH.*gumbo@s|^\(.*\)\$|# \1|" \ + %{nil} +sed -i \ + gumbo-parser/src/char_ref.c \ + -e '\@^#line [0-9]@s|^\(.*\)$|// \1|' +sed -i \ + gumbo-parser/src/Makefile \ + -e 's|^\(CFLAGS.*=.*\)$|\1 -fPIC|' +env LANG=C.UTF-8 gem build %{gem_name}-%{version}.gemspec %build -mkdir -p ./%{gem_dir} export NOKOGIRI_USE_SYSTEM_LIBRARIES=yes +%set_build_flags +pushd gumbo-parser/src/ +make libgumbo.a +popd %gem_install chmod 0644 .%{gem_dir}/cache/%{gem_name}-%{mainver}%{?prever}.gem rm -f .%{gem_instdir}/lib/*.jar @@ -93,6 +86,7 @@ rm -rf .%{gem_instdir}/ext/java %install mkdir -p %{buildroot}%{gem_dir} cp -a ./%{gem_dir}/* %{buildroot}%{gem_dir} +cp -a ./gumbo-parser %{buildroot}%{gem_instdir}/ find %{buildroot} -name \*.orig_\* | xargs rm -vf mkdir -p %{buildroot}%{gem_extdir_mri} cp -a ./%{gem_extdir_mri}/* %{buildroot}%{gem_extdir_mri}/ @@ -108,17 +102,24 @@ do chmod 0644 $f done cp -p %{gem_name}-%{version}/[A-Z]* %{buildroot}%{gem_instdir}/ -rm -rf %{buildroot}%{gem_instdir}/ext/%{gem_name}/ -rm -rf %{buildroot}%{gem_instdir}/tmp/ -rm -f %{buildroot}%{gem_instdir}/{.autotest,.require_paths,.gemtest,.travis.yml} -rm -f %{buildroot}%{gem_instdir}/appveyor.yml -rm -f %{buildroot}%{gem_instdir}/.cross_rubies -rm -f %{buildroot}%{gem_instdir}/{build_all,dependencies.yml,test_all} -rm -f %{buildroot}%{gem_instdir}/.editorconfig -rm -rf %{buildroot}%{gem_instdir}/suppressions/ -rm -rf %{buildroot}%{gem_instdir}/patches/ -rm -f %{buildroot}%{gem_instdir}/{Rakefile,Gemfile*} -rm -f %{buildroot}%{gem_instdir}/Manifest.txt +pushd %{buildroot}%{gem_instdir} +rm -rf \ + Gemfile* \ + dependencies.yml \ + ext \ + *gemspec \ + patches \ + ports \ + %{nil} +pushd gumbo-parser +rm \ + Makefile \ + %{nil} +find src -type f | \ + grep -v README.md | \ + xargs rm -f +popd +rm -f %{buildroot}%{gem_cache} %check export TZ="Asia/Tokyo" @@ -127,8 +128,11 @@ cp -a %{gem_name}-%{version}/test/ ./%{gem_instdir} pushd ./%{gem_instdir} sed -i test/helper.rb \ -e '\@require.*simplecov@,\@^end$@d' -ruby \ - -I.:lib:test:ext \ +sed -i '/require..minitest.reporters./ s/^/#/' test/helper.rb +sed -i '/Minitest::Reporters/ s/^/#/' test/helper.rb +env \ + RUBYLIB=".:lib:test:ext" \ + ruby \ -e \ "require 'test/helper' ; Dir.glob('test/**/test_*.rb'){|f| require f}" || \ exit 1 @@ -140,29 +144,28 @@ done popd %files -%defattr(-,root, root,-) %{_bindir}/%{gem_name} %{gem_extdir_mri}/ %dir %{gem_instdir}/ %doc %{gem_instdir}/[A-Z]* %{gem_instdir}/bin/ %{gem_instdir}/lib/ -%exclude %{gem_dir}/cache/%{gem_name}-%{mainver}%{?prever}.gem -%{gem_dir}/specifications/%{gem_name}-%{mainver}%{?prever}.gemspec -%if 0 -%files jruby -%defattr(-,root,root,-) -%{gem_instdir}/ext/java/ -%endif +%dir %{gem_instdir}/gumbo-parser +%dir %{gem_instdir}/gumbo-parser/src +%doc %{gem_instdir}/gumbo-parser/[A-Z]* +%doc %{gem_instdir}/gumbo-parser/src/README.md + +%{gem_dir}/specifications/%{gem_name}-%{mainver}%{?prever}.gemspec %files doc %defattr(-,root,root,-) -%exclude %{gem_instdir}/tasks/ -%exclude %{gem_instdir}/test/ %{gem_dir}/doc/%{gem_name}-%{mainver}%{?prever}/ %changelog +* Thu Mar 03 2022 jiangxinyu - 1.13.1-1 +- update to 1.13.1 + * Fri Jan 07 2022 liyanan - 1.10.5-5 - fix canonicalize already defined by glibc diff --git a/v1.10.5.tar.gz b/v1.10.5.tar.gz deleted file mode 100644 index efd89f66d7b0e57e999be9207c4dae356bd28b07..0000000000000000000000000000000000000000 Binary files a/v1.10.5.tar.gz and /dev/null differ