Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package rubygem-nokogiri for openSUSE:Factory checked in at 2022-08-07 18:33:54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/rubygem-nokogiri (Old) and /work/SRC/openSUSE:Factory/.rubygem-nokogiri.new.1521 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "rubygem-nokogiri" Sun Aug 7 18:33:54 2022 rev:64 rq:993503 version:1.13.8 Changes: -------- --- /work/SRC/openSUSE:Factory/rubygem-nokogiri/rubygem-nokogiri.changes 2022-06-03 14:15:35.261232385 +0200 +++ /work/SRC/openSUSE:Factory/.rubygem-nokogiri.new.1521/rubygem-nokogiri.changes 2022-08-07 18:34:00.625166916 +0200 @@ -1,0 +2,7 @@ +Thu Aug 4 13:20:37 UTC 2022 - Stephan Kulow <co...@suse.com> + +updated to version 1.13.8 + see installed CHANGES.md + + +------------------------------------------------------------------- Old: ---- nokogiri-1.13.6.gem New: ---- nokogiri-1.13.8.gem ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ rubygem-nokogiri.spec ++++++ --- /var/tmp/diff_new_pack.LKlHx5/_old 2022-08-07 18:34:02.129171288 +0200 +++ /var/tmp/diff_new_pack.LKlHx5/_new 2022-08-07 18:34:02.133171299 +0200 @@ -24,7 +24,7 @@ # Name: rubygem-nokogiri -Version: 1.13.6 +Version: 1.13.8 Release: 0 %define mod_name nokogiri %define mod_full_name %{mod_name}-%{version} ++++++ nokogiri-1.13.6.gem -> nokogiri-1.13.8.gem ++++++ Binary files old/checksums.yaml.gz and new/checksums.yaml.gz differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ext/nokogiri/extconf.rb new/ext/nokogiri/extconf.rb --- old/ext/nokogiri/extconf.rb 2022-05-08 16:15:46.000000000 +0200 +++ new/ext/nokogiri/extconf.rb 2022-07-23 16:04:48.000000000 +0200 @@ -973,6 +973,8 @@ have_func("xmlRelaxNGSetValidStructuredErrors") # introduced in libxml 2.6.21 have_func("xmlSchemaSetValidStructuredErrors") # introduced in libxml 2.6.23 have_func("xmlSchemaSetParserStructuredErrors") # introduced in libxml 2.6.23 +have_func("rb_gc_location") # introduced in Ruby 2.7 +have_func("rb_category_warning") # introduced in Ruby 3.0 have_func("vasprintf") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ext/nokogiri/gumbo.c new/ext/nokogiri/gumbo.c --- old/ext/nokogiri/gumbo.c 2022-05-08 16:15:46.000000000 +0200 +++ new/ext/nokogiri/gumbo.c 2022-07-23 16:04:48.000000000 +0200 @@ -401,7 +401,7 @@ extract_xml_node(VALUE node) { xmlNodePtr xml_node; - Data_Get_Struct(node, xmlNode, xml_node); + Noko_Node_Get_Struct(node, xmlNode, xml_node); return xml_node; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ext/nokogiri/nokogiri.h new/ext/nokogiri/nokogiri.h --- old/ext/nokogiri/nokogiri.h 2022-05-08 16:15:46.000000000 +0200 +++ new/ext/nokogiri/nokogiri.h 2022-07-23 16:04:48.000000000 +0200 @@ -170,6 +170,8 @@ int noko_io_write(void *ctx, char *buffer, int len); int noko_io_close(void *ctx); +#define Noko_Node_Get_Struct(obj,type,sval) ((sval) = (type*)DATA_PTR(obj)) + VALUE noko_xml_node_wrap(VALUE klass, xmlNodePtr node) ; VALUE noko_xml_node_wrap_node_set_result(xmlNodePtr node, VALUE node_set) ; VALUE noko_xml_node_attrs(xmlNodePtr node) ; @@ -200,6 +202,12 @@ #define DISCARD_CONST_QUAL(t, v) ((t)(uintptr_t)(v)) #define DISCARD_CONST_QUAL_XMLCHAR(v) DISCARD_CONST_QUAL(xmlChar *, v) +#if HAVE_RB_CATEGORY_WARNING +# define NOKO_WARN_DEPRECATION(message) rb_category_warning(RB_WARN_CATEGORY_DEPRECATED, message) +#else +# define NOKO_WARN_DEPRECATION(message) rb_warning(message) +#endif + void Nokogiri_structured_error_func_save(libxmlStructuredErrorHandlerState *handler_state); void Nokogiri_structured_error_func_save_and_set(libxmlStructuredErrorHandlerState *handler_state, void *user_data, xmlStructuredErrorFunc handler); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ext/nokogiri/xml_attr.c new/ext/nokogiri/xml_attr.c --- old/ext/nokogiri/xml_attr.c 2022-05-08 16:15:46.000000000 +0200 +++ new/ext/nokogiri/xml_attr.c 2022-07-23 16:04:48.000000000 +0200 @@ -16,7 +16,7 @@ xmlChar *value; xmlNode *cur; - Data_Get_Struct(self, xmlAttr, attr); + Noko_Node_Get_Struct(self, xmlAttr, attr); if (attr->children) { xmlFreeNodeList(attr->children); @@ -68,7 +68,7 @@ rb_raise(rb_eArgError, "parameter must be a Nokogiri::XML::Document"); } - Data_Get_Struct(document, xmlDoc, xml_doc); + Noko_Node_Get_Struct(document, xmlDoc, xml_doc); node = xmlNewDocProp( xml_doc, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ext/nokogiri/xml_attribute_decl.c new/ext/nokogiri/xml_attribute_decl.c --- old/ext/nokogiri/xml_attribute_decl.c 2022-05-08 16:15:46.000000000 +0200 +++ new/ext/nokogiri/xml_attribute_decl.c 2022-07-23 16:04:48.000000000 +0200 @@ -12,7 +12,7 @@ attribute_type(VALUE self) { xmlAttributePtr node; - Data_Get_Struct(self, xmlAttribute, node); + Noko_Node_Get_Struct(self, xmlAttribute, node); return INT2NUM((long)node->atype); } @@ -26,7 +26,7 @@ default_value(VALUE self) { xmlAttributePtr node; - Data_Get_Struct(self, xmlAttribute, node); + Noko_Node_Get_Struct(self, xmlAttribute, node); if (node->defaultValue) { return NOKOGIRI_STR_NEW2(node->defaultValue); } return Qnil; @@ -45,7 +45,7 @@ xmlEnumerationPtr enm; VALUE list; - Data_Get_Struct(self, xmlAttribute, node); + Noko_Node_Get_Struct(self, xmlAttribute, node); list = rb_ary_new(); enm = node->tree; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ext/nokogiri/xml_cdata.c new/ext/nokogiri/xml_cdata.c --- old/ext/nokogiri/xml_cdata.c 2022-05-08 16:15:46.000000000 +0200 +++ new/ext/nokogiri/xml_cdata.c 2022-07-23 16:04:48.000000000 +0200 @@ -25,7 +25,7 @@ rb_scan_args(argc, argv, "2*", &doc, &content, &rest); - Data_Get_Struct(doc, xmlDoc, xml_doc); + Noko_Node_Get_Struct(doc, xmlDoc, xml_doc); if (!NIL_P(content)) { content_str = (xmlChar *)StringValuePtr(content); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ext/nokogiri/xml_document.c new/ext/nokogiri/xml_document.c --- old/ext/nokogiri/xml_document.c 2022-05-08 16:15:46.000000000 +0200 +++ new/ext/nokogiri/xml_document.c 2022-07-23 16:04:48.000000000 +0200 @@ -161,7 +161,7 @@ rb_obj_class(rb_new_root)); } - Data_Get_Struct(rb_new_root, xmlNode, c_new_root); + Noko_Node_Get_Struct(rb_new_root, xmlNode, c_new_root); /* If the new root's document is not the same as the current document, * then we need to dup the node in to this document. */ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ext/nokogiri/xml_dtd.c new/ext/nokogiri/xml_dtd.c --- old/ext/nokogiri/xml_dtd.c 2022-05-08 16:15:46.000000000 +0200 +++ new/ext/nokogiri/xml_dtd.c 2022-07-23 16:04:48.000000000 +0200 @@ -44,7 +44,7 @@ xmlDtdPtr dtd; VALUE hash; - Data_Get_Struct(self, xmlDtd, dtd); + Noko_Node_Get_Struct(self, xmlDtd, dtd); if (!dtd->entities) { return Qnil; } @@ -67,7 +67,7 @@ xmlDtdPtr dtd; VALUE hash; - Data_Get_Struct(self, xmlDtd, dtd); + Noko_Node_Get_Struct(self, xmlDtd, dtd); if (!dtd->notations) { return Qnil; } @@ -90,7 +90,7 @@ xmlDtdPtr dtd; VALUE hash; - Data_Get_Struct(self, xmlDtd, dtd); + Noko_Node_Get_Struct(self, xmlDtd, dtd); hash = rb_hash_new(); @@ -113,7 +113,7 @@ xmlDtdPtr dtd; VALUE hash; - Data_Get_Struct(self, xmlDtd, dtd); + Noko_Node_Get_Struct(self, xmlDtd, dtd); if (!dtd->elements) { return Qnil; } @@ -138,8 +138,8 @@ xmlValidCtxtPtr ctxt; VALUE error_list; - Data_Get_Struct(self, xmlDtd, dtd); - Data_Get_Struct(document, xmlDoc, doc); + Noko_Node_Get_Struct(self, xmlDtd, dtd); + Noko_Node_Get_Struct(document, xmlDoc, doc); error_list = rb_ary_new(); ctxt = xmlNewValidCtxt(); @@ -165,7 +165,7 @@ system_id(VALUE self) { xmlDtdPtr dtd; - Data_Get_Struct(self, xmlDtd, dtd); + Noko_Node_Get_Struct(self, xmlDtd, dtd); if (!dtd->SystemID) { return Qnil; } @@ -182,7 +182,7 @@ external_id(VALUE self) { xmlDtdPtr dtd; - Data_Get_Struct(self, xmlDtd, dtd); + Noko_Node_Get_Struct(self, xmlDtd, dtd); if (!dtd->ExternalID) { return Qnil; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ext/nokogiri/xml_element_decl.c new/ext/nokogiri/xml_element_decl.c --- old/ext/nokogiri/xml_element_decl.c 2022-05-08 16:15:46.000000000 +0200 +++ new/ext/nokogiri/xml_element_decl.c 2022-07-23 16:04:48.000000000 +0200 @@ -14,7 +14,7 @@ element_type(VALUE self) { xmlElementPtr node; - Data_Get_Struct(self, xmlElement, node); + Noko_Node_Get_Struct(self, xmlElement, node); return INT2NUM((long)node->etype); } @@ -28,7 +28,7 @@ content(VALUE self) { xmlElementPtr node; - Data_Get_Struct(self, xmlElement, node); + Noko_Node_Get_Struct(self, xmlElement, node); if (!node->content) { return Qnil; } @@ -48,7 +48,7 @@ prefix(VALUE self) { xmlElementPtr node; - Data_Get_Struct(self, xmlElement, node); + Noko_Node_Get_Struct(self, xmlElement, node); if (!node->prefix) { return Qnil; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ext/nokogiri/xml_entity_decl.c new/ext/nokogiri/xml_entity_decl.c --- old/ext/nokogiri/xml_entity_decl.c 2022-05-08 16:15:46.000000000 +0200 +++ new/ext/nokogiri/xml_entity_decl.c 2022-07-23 16:04:48.000000000 +0200 @@ -12,7 +12,7 @@ original_content(VALUE self) { xmlEntityPtr node; - Data_Get_Struct(self, xmlEntity, node); + Noko_Node_Get_Struct(self, xmlEntity, node); if (!node->orig) { return Qnil; } @@ -29,7 +29,7 @@ get_content(VALUE self) { xmlEntityPtr node; - Data_Get_Struct(self, xmlEntity, node); + Noko_Node_Get_Struct(self, xmlEntity, node); if (!node->content) { return Qnil; } @@ -46,7 +46,7 @@ entity_type(VALUE self) { xmlEntityPtr node; - Data_Get_Struct(self, xmlEntity, node); + Noko_Node_Get_Struct(self, xmlEntity, node); return INT2NUM((int)node->etype); } @@ -61,7 +61,7 @@ external_id(VALUE self) { xmlEntityPtr node; - Data_Get_Struct(self, xmlEntity, node); + Noko_Node_Get_Struct(self, xmlEntity, node); if (!node->ExternalID) { return Qnil; } @@ -78,7 +78,7 @@ system_id(VALUE self) { xmlEntityPtr node; - Data_Get_Struct(self, xmlEntity, node); + Noko_Node_Get_Struct(self, xmlEntity, node); if (!node->SystemID) { return Qnil; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ext/nokogiri/xml_node.c new/ext/nokogiri/xml_node.c --- old/ext/nokogiri/xml_node.c 2022-05-08 16:15:46.000000000 +0200 +++ new/ext/nokogiri/xml_node.c 2022-07-23 16:04:48.000000000 +0200 @@ -7,7 +7,6 @@ typedef xmlNodePtr(*pivot_reparentee_func)(xmlNodePtr, xmlNodePtr); - #ifdef DEBUG static void _xml_node_dealloc(xmlNodePtr x) @@ -19,10 +18,13 @@ # define _xml_node_dealloc 0 #endif - static void _xml_node_mark(xmlNodePtr node) { + if (!DOC_RUBY_OBJECT_TEST(node->doc)) { + return; + } + xmlDocPtr doc = node->doc; if (doc->type == XML_DOCUMENT_NODE || doc->type == XML_HTML_DOCUMENT_NODE) { if (DOC_RUBY_OBJECT_TEST(doc)) { @@ -33,6 +35,31 @@ } } +#ifdef HAVE_RB_GC_LOCATION +static void +_xml_node_update_references(xmlNodePtr node) +{ + if (node->_private) { + node->_private = (void *)rb_gc_location((VALUE)node->_private); + } +} +#endif + +typedef void (*gc_callback_t)(void *); + +static const rb_data_type_t nokogiri_node_type = { + "Nokogiri/XMLNode", + { + (gc_callback_t)_xml_node_mark, (gc_callback_t)_xml_node_dealloc, 0, +#ifdef HAVE_RB_GC_LOCATION + (gc_callback_t)_xml_node_update_references +#endif + }, + 0, 0, +#ifdef RUBY_TYPED_FREE_IMMEDIATELY + RUBY_TYPED_FREE_IMMEDIATELY, +#endif +}; static void relink_namespace(xmlNodePtr reparented) @@ -198,8 +225,8 @@ rb_raise(rb_eArgError, "node must be a Nokogiri::XML::Node"); } - Data_Get_Struct(reparentee_obj, xmlNode, reparentee); - Data_Get_Struct(pivot_obj, xmlNode, pivot); + Noko_Node_Get_Struct(reparentee_obj, xmlNode, reparentee); + Noko_Node_Get_Struct(pivot_obj, xmlNode, pivot); /* * Check if nodes given are appropriate to have a parent-child @@ -439,7 +466,7 @@ xmlNsPtr c_namespace; const xmlChar *c_prefix = (const xmlChar *)(NIL_P(rb_prefix) ? NULL : StringValueCStr(rb_prefix)); - Data_Get_Struct(rb_node, xmlNode, c_node); + Noko_Node_Get_Struct(rb_node, xmlNode, c_node); element = c_node ; c_namespace = xmlSearchNs(c_node->doc, c_node, c_prefix); @@ -506,7 +533,7 @@ { xmlNodePtr node; xmlAttrPtr prop; - Data_Get_Struct(self, xmlNode, node); + Noko_Node_Get_Struct(self, xmlNode, node); prop = xmlHasProp(node, (xmlChar *)StringValueCStr(name)); if (! prop) { return Qnil; } @@ -557,7 +584,7 @@ { xmlNodePtr c_node; - Data_Get_Struct(rb_node, xmlNode, c_node); + Noko_Node_Get_Struct(rb_node, xmlNode, c_node); return noko_xml_node_attrs(c_node); } @@ -609,7 +636,7 @@ { xmlNodePtr node; xmlAttrPtr prop; - Data_Get_Struct(self, xmlNode, node); + Noko_Node_Get_Struct(self, xmlNode, node); prop = xmlHasNsProp(node, (xmlChar *)StringValueCStr(name), NIL_P(namespace) ? NULL : (xmlChar *)StringValueCStr(namespace)); @@ -636,7 +663,7 @@ rb_xml_node_blank_eh(VALUE self) { xmlNodePtr node; - Data_Get_Struct(self, xmlNode, node); + Noko_Node_Get_Struct(self, xmlNode, node); return (1 == xmlIsBlankNode(node)) ? Qtrue : Qfalse ; } @@ -658,7 +685,7 @@ rb_xml_node_child(VALUE self) { xmlNodePtr node, child; - Data_Get_Struct(self, xmlNode, node); + Noko_Node_Get_Struct(self, xmlNode, node); child = node->children; if (!child) { return Qnil; } @@ -683,7 +710,7 @@ VALUE document; VALUE node_set; - Data_Get_Struct(self, xmlNode, node); + Noko_Node_Get_Struct(self, xmlNode, node); child = node->children; set = xmlXPathNodeSetCreate(child); @@ -742,7 +769,7 @@ xmlNodePtr node; xmlChar *content; - Data_Get_Struct(self, xmlNode, node); + Noko_Node_Get_Struct(self, xmlNode, node); content = xmlNodeGetContent(node); if (content) { @@ -765,7 +792,7 @@ rb_xml_node_document(VALUE self) { xmlNodePtr node; - Data_Get_Struct(self, xmlNode, node); + Noko_Node_Get_Struct(self, xmlNode, node); return DOC_RUBY_OBJECT(node->doc); } @@ -780,7 +807,7 @@ rb_xml_node_pointer_id(VALUE self) { xmlNodePtr node; - Data_Get_Struct(self, xmlNode, node); + Noko_Node_Get_Struct(self, xmlNode, node); return INT2NUM((long)(node)); } @@ -797,7 +824,7 @@ xmlChar *encoded; VALUE encoded_str; - Data_Get_Struct(self, xmlNode, node); + Noko_Node_Get_Struct(self, xmlNode, node); encoded = xmlEncodeSpecialChars( node->doc, (const xmlChar *)StringValueCStr(string) @@ -828,7 +855,7 @@ xmlDocPtr doc; xmlDtdPtr dtd; - Data_Get_Struct(self, xmlNode, node); + Noko_Node_Get_Struct(self, xmlNode, node); doc = node->doc; @@ -861,7 +888,7 @@ xmlDocPtr doc; xmlDtdPtr dtd; - Data_Get_Struct(self, xmlNode, node); + Noko_Node_Get_Struct(self, xmlNode, node); doc = node->doc; @@ -894,7 +921,7 @@ xmlDocPtr doc; xmlDtdPtr dtd; - Data_Get_Struct(self, xmlNode, node); + Noko_Node_Get_Struct(self, xmlNode, node); if (!node->doc) { return Qnil; } @@ -919,7 +946,7 @@ xmlDocPtr doc; xmlDtdPtr dtd; - Data_Get_Struct(self, xmlNode, node); + Noko_Node_Get_Struct(self, xmlNode, node); if (!node->doc) { return Qnil; } @@ -955,7 +982,7 @@ xmlDocPtr new_parent_doc; xmlNodePtr node, dup; - Data_Get_Struct(self, xmlNode, node); + Noko_Node_Get_Struct(self, xmlNode, node); n_args = rb_scan_args(argc, argv, "02", &r_level, &r_new_parent_doc); @@ -988,7 +1015,7 @@ unlink_node(VALUE self) { xmlNodePtr node; - Data_Get_Struct(self, xmlNode, node); + Noko_Node_Get_Struct(self, xmlNode, node); xmlUnlinkNode(node); noko_xml_document_pin_node(node); return self; @@ -1005,7 +1032,7 @@ next_sibling(VALUE self) { xmlNodePtr node, sibling; - Data_Get_Struct(self, xmlNode, node); + Noko_Node_Get_Struct(self, xmlNode, node); sibling = node->next; if (!sibling) { return Qnil; } @@ -1023,7 +1050,7 @@ previous_sibling(VALUE self) { xmlNodePtr node, sibling; - Data_Get_Struct(self, xmlNode, node); + Noko_Node_Get_Struct(self, xmlNode, node); sibling = node->prev; if (!sibling) { return Qnil; } @@ -1041,7 +1068,7 @@ next_element(VALUE self) { xmlNodePtr node, sibling; - Data_Get_Struct(self, xmlNode, node); + Noko_Node_Get_Struct(self, xmlNode, node); sibling = xmlNextElementSibling(node); if (!sibling) { return Qnil; } @@ -1059,7 +1086,7 @@ previous_element(VALUE self) { xmlNodePtr node, sibling; - Data_Get_Struct(self, xmlNode, node); + Noko_Node_Get_Struct(self, xmlNode, node); /* * note that we don't use xmlPreviousElementSibling here because it's buggy pre-2.7.7. @@ -1081,7 +1108,7 @@ VALUE reparent = reparent_node_with(self, new_node, xmlReplaceNodeWrapper); xmlNodePtr pivot; - Data_Get_Struct(self, xmlNode, pivot); + Noko_Node_Get_Struct(self, xmlNode, pivot); noko_xml_document_pin_node(pivot); return reparent; @@ -1116,7 +1143,7 @@ VALUE document; VALUE node_set; - Data_Get_Struct(self, xmlNode, node); + Noko_Node_Get_Struct(self, xmlNode, node); child = xmlFirstElementChild(node); set = xmlXPathNodeSetCreate(child); @@ -1155,7 +1182,7 @@ rb_xml_node_first_element_child(VALUE self) { xmlNodePtr node, child; - Data_Get_Struct(self, xmlNode, node); + Noko_Node_Get_Struct(self, xmlNode, node); child = xmlFirstElementChild(node); if (!child) { return Qnil; } @@ -1182,7 +1209,7 @@ rb_xml_node_last_element_child(VALUE self) { xmlNodePtr node, child; - Data_Get_Struct(self, xmlNode, node); + Noko_Node_Get_Struct(self, xmlNode, node); child = xmlLastElementChild(node); if (!child) { return Qnil; } @@ -1200,7 +1227,7 @@ key_eh(VALUE self, VALUE attribute) { xmlNodePtr node; - Data_Get_Struct(self, xmlNode, node); + Noko_Node_Get_Struct(self, xmlNode, node); if (xmlHasProp(node, (xmlChar *)StringValueCStr(attribute))) { return Qtrue; } @@ -1217,7 +1244,7 @@ namespaced_key_eh(VALUE self, VALUE attribute, VALUE namespace) { xmlNodePtr node; - Data_Get_Struct(self, xmlNode, node); + Noko_Node_Get_Struct(self, xmlNode, node); if (xmlHasNsProp(node, (xmlChar *)StringValueCStr(attribute), NIL_P(namespace) ? NULL : (xmlChar *)StringValueCStr(namespace))) { return Qtrue; @@ -1236,7 +1263,7 @@ { xmlNodePtr node, cur; xmlAttrPtr prop; - Data_Get_Struct(self, xmlNode, node); + Noko_Node_Get_Struct(self, xmlNode, node); /* If a matching attribute node already exists, then xmlSetProp will destroy * the existing node's children. However, if Nokogiri has a node object @@ -1281,7 +1308,7 @@ if (NIL_P(rattribute)) { return Qnil; } - Data_Get_Struct(self, xmlNode, node); + Noko_Node_Get_Struct(self, xmlNode, node); attribute = xmlCharStrdup(StringValueCStr(rattribute)); colon = DISCARD_CONST_QUAL_XMLCHAR(xmlStrchr(attribute, (const xmlChar)':')); @@ -1323,7 +1350,7 @@ xmlNodePtr node; xmlNsPtr ns = NULL; - Data_Get_Struct(self, xmlNode, node); + Noko_Node_Get_Struct(self, xmlNode, node); if (!NIL_P(namespace)) { Data_Get_Struct(namespace, xmlNs, ns); @@ -1360,7 +1387,7 @@ rb_xml_node_namespace(VALUE rb_node) { xmlNodePtr c_node ; - Data_Get_Struct(rb_node, xmlNode, c_node); + Noko_Node_Get_Struct(rb_node, xmlNode, c_node); if (c_node->ns) { return noko_xml_namespace_wrap(c_node->ns, c_node->doc); @@ -1405,7 +1432,7 @@ xmlNsPtr c_namespace; VALUE definitions = rb_ary_new(); - Data_Get_Struct(rb_node, xmlNode, c_node); + Noko_Node_Get_Struct(rb_node, xmlNode, c_node); c_namespace = c_node->nsDef; if (!c_namespace) { @@ -1456,7 +1483,7 @@ VALUE scopes = rb_ary_new(); int j; - Data_Get_Struct(rb_node, xmlNode, c_node); + Noko_Node_Get_Struct(rb_node, xmlNode, c_node); namespaces = xmlGetNsList(c_node->doc, c_node); if (!namespaces) { @@ -1481,7 +1508,7 @@ node_type(VALUE self) { xmlNodePtr node; - Data_Get_Struct(self, xmlNode, node); + Noko_Node_Get_Struct(self, xmlNode, node); return INT2NUM((long)node->type); } @@ -1495,7 +1522,7 @@ set_native_content(VALUE self, VALUE content) { xmlNodePtr node, child, next ; - Data_Get_Struct(self, xmlNode, node); + Noko_Node_Get_Struct(self, xmlNode, node); child = node->children; while (NULL != child) { @@ -1521,7 +1548,7 @@ xmlNodePtr self ; xmlChar *lang ; - Data_Get_Struct(self_rb, xmlNode, self); + Noko_Node_Get_Struct(self_rb, xmlNode, self); lang = (xmlChar *)StringValueCStr(lang_rb); xmlNodeSetLang(self, lang); @@ -1543,7 +1570,7 @@ xmlChar *lang ; VALUE lang_rb ; - Data_Get_Struct(self_rb, xmlNode, self); + Noko_Node_Get_Struct(self_rb, xmlNode, self); lang = xmlNodeGetLang(self); if (lang) { @@ -1572,7 +1599,7 @@ get_parent(VALUE self) { xmlNodePtr node, parent; - Data_Get_Struct(self, xmlNode, node); + Noko_Node_Get_Struct(self, xmlNode, node); parent = node->parent; if (!parent) { return Qnil; } @@ -1590,7 +1617,7 @@ set_name(VALUE self, VALUE new_name) { xmlNodePtr node; - Data_Get_Struct(self, xmlNode, node); + Noko_Node_Get_Struct(self, xmlNode, node); xmlNodeSetName(node, (xmlChar *)StringValueCStr(new_name)); return new_name; } @@ -1605,7 +1632,7 @@ get_name(VALUE self) { xmlNodePtr node; - Data_Get_Struct(self, xmlNode, node); + Noko_Node_Get_Struct(self, xmlNode, node); if (node->name) { return NOKOGIRI_STR_NEW2(node->name); } @@ -1625,7 +1652,7 @@ xmlChar *c_path ; VALUE rval; - Data_Get_Struct(rb_node, xmlNode, c_node); + Noko_Node_Get_Struct(rb_node, xmlNode, c_node); c_path = xmlGetNodePath(c_node); if (c_path == NULL) { @@ -1674,7 +1701,7 @@ const char *before_indent; xmlSaveCtxtPtr savectx; - Data_Get_Struct(self, xmlNode, node); + Noko_Node_Get_Struct(self, xmlNode, node); xmlIndentTreeOutput = 1; @@ -1728,7 +1755,7 @@ rb_xml_node_line(VALUE rb_node) { xmlNodePtr c_node; - Data_Get_Struct(rb_node, xmlNode, c_node); + Noko_Node_Get_Struct(rb_node, xmlNode, c_node); return INT2NUM(xmlGetLineNo(c_node)); } @@ -1745,7 +1772,7 @@ xmlNodePtr c_node; int line_number = NUM2INT(rb_line_number); - Data_Get_Struct(rb_node, xmlNode, c_node); + Noko_Node_Get_Struct(rb_node, xmlNode, c_node); // libxml2 optionally uses xmlNode.psvi to store longer line numbers, but only for text nodes. // search for "psvi" in SAX2.c and tree.c to learn more. @@ -1779,9 +1806,9 @@ } if (!rb_obj_is_kind_of(rb_document_node, cNokogiriXmlDocument)) { // TODO: deprecate allowing Node - rb_warn("Passing a Node as the second parameter to Node.new is deprecated. Please pass a Document instead, or prefer an alternative constructor like Node#add_child. This will become an error in a future release of Nokogiri."); + NOKO_WARN_DEPRECATION("Passing a Node as the second parameter to Node.new is deprecated. Please pass a Document instead, or prefer an alternative constructor like Node#add_child. This will become an error in a future release of Nokogiri."); } - Data_Get_Struct(rb_document_node, xmlNode, c_document_node); + Noko_Node_Get_Struct(rb_document_node, xmlNode, c_document_node); c_node = xmlNewNode(NULL, (xmlChar *)StringValueCStr(rb_name)); c_node->doc = c_document_node->doc; @@ -1811,7 +1838,7 @@ xmlNodePtr node ; VALUE html; - Data_Get_Struct(self, xmlNode, node); + Noko_Node_Get_Struct(self, xmlNode, node); buf = xmlBufferCreate() ; htmlNodeDump(buf, node->doc, node); @@ -1830,8 +1857,8 @@ compare(VALUE self, VALUE _other) { xmlNodePtr node, other; - Data_Get_Struct(self, xmlNode, node); - Data_Get_Struct(_other, xmlNode, other); + Noko_Node_Get_Struct(self, xmlNode, node); + Noko_Node_Get_Struct(_other, xmlNode, other); return INT2NUM((long)xmlXPathCmpNodes(other, node)); } @@ -1851,7 +1878,7 @@ xmlNodePtr node; VALUE error_list = rb_ary_new(); - Data_Get_Struct(self, xmlNode, node); + Noko_Node_Get_Struct(self, xmlNode, node); xmlSetStructuredErrorFunc((void *)error_list, Nokogiri_error_array_pusher); rcode = xmlXIncludeProcessTreeFlags(node, (int)NUM2INT(options)); @@ -1882,7 +1909,7 @@ VALUE doc, err; int doc_is_empty; - Data_Get_Struct(self, xmlNode, node); + Noko_Node_Get_Struct(self, xmlNode, node); doc = DOC_RUBY_OBJECT(node->doc); err = rb_iv_get(doc, "@errors"); @@ -1974,14 +2001,12 @@ return noko_xml_node_set_wrap(set, doc); } - VALUE noko_xml_node_wrap(VALUE rb_class, xmlNodePtr c_node) { VALUE rb_document, rb_node_cache, rb_node; nokogiriTuplePtr node_has_a_document; xmlDocPtr c_doc; - void (*f_mark)(xmlNodePtr) = NULL ; assert(c_node); @@ -1989,11 +2014,9 @@ return DOC_RUBY_OBJECT(c_node->doc); } - /* It's OK if the node doesn't have a fully-realized document (as in XML::Reader). */ - /* see https://github.com/sparklemotion/nokogiri/issues/95 */ - /* and https://github.com/sparklemotion/nokogiri/issues/439 */ c_doc = c_node->doc; - if (c_doc->type == XML_DOCUMENT_FRAG_NODE) { c_doc = c_doc->doc; } + + // Nodes yielded from XML::Reader don't have a fully-realized Document node_has_a_document = DOC_RUBY_OBJECT_TEST(c_doc); if (c_node->_private && node_has_a_document) { @@ -2043,9 +2066,7 @@ } } - f_mark = node_has_a_document ? _xml_node_mark : NULL ; - - rb_node = Data_Wrap_Struct(rb_class, f_mark, _xml_node_dealloc, c_node) ; + rb_node = TypedData_Wrap_Struct(rb_class, &nokogiri_node_type, c_node) ; c_node->_private = (void *)rb_node; if (node_has_a_document) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ext/nokogiri/xml_node_set.c new/ext/nokogiri/xml_node_set.c --- old/ext/nokogiri/xml_node_set.c 2022-05-08 16:15:46.000000000 +0200 +++ new/ext/nokogiri/xml_node_set.c 2022-07-23 16:04:48.000000000 +0200 @@ -156,7 +156,7 @@ Check_Node_Set_Node_Type(rb_node); Data_Get_Struct(self, xmlNodeSet, node_set); - Data_Get_Struct(rb_node, xmlNode, node); + Noko_Node_Get_Struct(rb_node, xmlNode, node); xmlXPathNodeSetAdd(node_set, node); @@ -179,7 +179,7 @@ Check_Node_Set_Node_Type(rb_node); Data_Get_Struct(self, xmlNodeSet, node_set); - Data_Get_Struct(rb_node, xmlNode, node); + Noko_Node_Get_Struct(rb_node, xmlNode, node); if (xmlXPathNodeSetContains(node_set, node)) { xpath_node_set_del(node_set, node); @@ -228,7 +228,7 @@ Check_Node_Set_Node_Type(rb_node); Data_Get_Struct(self, xmlNodeSet, node_set); - Data_Get_Struct(rb_node, xmlNode, node); + Noko_Node_Get_Struct(rb_node, xmlNode, node); return (xmlXPathNodeSetContains(node_set, node) ? Qtrue : Qfalse); } @@ -430,7 +430,7 @@ xmlNodePtr node_ptr; node = noko_xml_node_wrap(Qnil, node_set->nodeTab[j]); rb_funcall(node, rb_intern("unlink"), 0); /* modifies the C struct out from under the object */ - Data_Get_Struct(node, xmlNode, node_ptr); + Noko_Node_Get_Struct(node, xmlNode, node_ptr); node_set->nodeTab[j] = node_ptr ; } } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ext/nokogiri/xml_reader.c new/ext/nokogiri/xml_reader.c --- old/ext/nokogiri/xml_reader.c 2022-05-08 16:15:46.000000000 +0200 +++ new/ext/nokogiri/xml_reader.c 2022-07-23 16:04:48.000000000 +0200 @@ -31,6 +31,7 @@ return (0); } +// TODO: merge this function into the `namespaces` method implementation static void Nokogiri_xml_node_namespaces(xmlNodePtr node, VALUE attr_hash) { @@ -150,7 +151,11 @@ /* :call-seq: attribute_nodes() ??? Array<Nokogiri::XML::Attr> - Get the attributes of the current node as an Array of Attr + Get the attributes of the current node as an Array of XML:Attr + + ??? This method is deprecated and unsafe to use. It will be removed in a future version of Nokogiri. + + See related: #attribute_hash, #attributes */ static VALUE rb_xml_reader_attribute_nodes(VALUE rb_reader) @@ -160,6 +165,10 @@ VALUE attr_nodes; int j; + // TODO: deprecated, remove in Nokogiri v1.15, see https://github.com/sparklemotion/nokogiri/issues/2598 + // After removal, we can also remove all the "node_has_a_document" special handling from xml_node.c + NOKO_WARN_DEPRECATION("Reader#attribute_nodes is deprecated and will be removed in a future version of Nokogiri. Please use Reader#attribute_hash instead."); + Data_Get_Struct(rb_reader, xmlTextReader, c_reader); if (! has_attributes(c_reader)) { @@ -182,6 +191,47 @@ } /* + :call-seq: attribute_hash() ??? Hash<String ??? String> + + Get the attributes of the current node as a Hash of names and values. + + See related: #attributes and #namespaces + */ +static VALUE +rb_xml_reader_attribute_hash(VALUE rb_reader) +{ + VALUE rb_attributes = rb_hash_new(); + xmlTextReaderPtr c_reader; + xmlNodePtr c_node; + xmlAttrPtr c_property; + + Data_Get_Struct(rb_reader, xmlTextReader, c_reader); + + if (!has_attributes(c_reader)) { + return rb_attributes; + } + + c_node = xmlTextReaderExpand(c_reader); + c_property = c_node->properties; + while (c_property != NULL) { + VALUE rb_name = NOKOGIRI_STR_NEW2(c_property->name); + VALUE rb_value = Qnil; + xmlChar *c_value = xmlNodeGetContent((xmlNode *)c_property); + + if (c_value) { + rb_value = NOKOGIRI_STR_NEW2(c_value); + xmlFree(c_value); + } + + rb_hash_aset(rb_attributes, rb_name, rb_value); + + c_property = c_property->next; + } + + return rb_attributes; +} + +/* * call-seq: * attribute_at(index) * @@ -696,6 +746,7 @@ rb_define_method(cNokogiriXmlReader, "attribute_at", attribute_at, 1); rb_define_method(cNokogiriXmlReader, "attribute_count", attribute_count, 0); rb_define_method(cNokogiriXmlReader, "attribute_nodes", rb_xml_reader_attribute_nodes, 0); + rb_define_method(cNokogiriXmlReader, "attribute_hash", rb_xml_reader_attribute_hash, 0); rb_define_method(cNokogiriXmlReader, "attributes?", attributes_eh, 0); rb_define_method(cNokogiriXmlReader, "base_uri", rb_xml_reader_base_uri, 0); rb_define_method(cNokogiriXmlReader, "default?", default_eh, 0); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ext/nokogiri/xml_schema.c new/ext/nokogiri/xml_schema.c --- old/ext/nokogiri/xml_schema.c 2022-05-08 16:15:46.000000000 +0200 +++ new/ext/nokogiri/xml_schema.c 2022-07-23 16:04:48.000000000 +0200 @@ -25,7 +25,7 @@ VALUE errors; Data_Get_Struct(self, xmlSchema, schema); - Data_Get_Struct(document, xmlDoc, doc); + Noko_Node_Get_Struct(document, xmlDoc, doc); errors = rb_ary_new(); @@ -179,7 +179,7 @@ for (i = 0; i < RARRAY_LEN(cache); i++) { xmlNodePtr node; VALUE element = rb_ary_entry(cache, i); - Data_Get_Struct(element, xmlNode, node); + Noko_Node_Get_Struct(element, xmlNode, node); if (xmlIsBlankNode(node)) { return 1; } @@ -210,7 +210,7 @@ scanned_args = rb_scan_args(argc, argv, "11", &document, &parse_options); - Data_Get_Struct(document, xmlDoc, doc); + Noko_Node_Get_Struct(document, xmlDoc, doc); doc = doc->doc; /* In case someone passes us a node. ugh. */ if (scanned_args == 1) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ext/nokogiri/xml_text.c new/ext/nokogiri/xml_text.c --- old/ext/nokogiri/xml_text.c 2022-05-08 16:15:46.000000000 +0200 +++ new/ext/nokogiri/xml_text.c 2022-07-23 16:04:48.000000000 +0200 @@ -20,7 +20,7 @@ rb_scan_args(argc, argv, "2*", &string, &document, &rest); - Data_Get_Struct(document, xmlDoc, doc); + Noko_Node_Get_Struct(document, xmlDoc, doc); node = xmlNewText((xmlChar *)StringValueCStr(string)); node->doc = doc->doc; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ext/nokogiri/xml_xpath_context.c new/ext/nokogiri/xml_xpath_context.c --- old/ext/nokogiri/xml_xpath_context.c 2022-05-08 16:15:46.000000000 +0200 +++ new/ext/nokogiri/xml_xpath_context.c 2022-07-23 16:04:48.000000000 +0200 @@ -371,7 +371,7 @@ xmlXPathContextPtr ctx; VALUE self; - Data_Get_Struct(nodeobj, xmlNode, node); + Noko_Node_Get_Struct(nodeobj, xmlNode, node); xmlXPathInit(); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/nokogiri/version/constant.rb new/lib/nokogiri/version/constant.rb --- old/lib/nokogiri/version/constant.rb 2022-05-08 16:15:46.000000000 +0200 +++ new/lib/nokogiri/version/constant.rb 2022-07-23 16:04:48.000000000 +0200 @@ -2,5 +2,5 @@ module Nokogiri # The version of Nokogiri you are using - VERSION = "1.13.6" + VERSION = "1.13.8" end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/nokogiri/xml/reader.rb new/lib/nokogiri/xml/reader.rb --- old/lib/nokogiri/xml/reader.rb 2022-05-08 16:15:46.000000000 +0200 +++ new/lib/nokogiri/xml/reader.rb 2022-07-23 16:04:48.000000000 +0200 @@ -83,16 +83,14 @@ end private :initialize - # Get the attributes of the current node as a Hash + # Get the attributes and namespaces of the current node as a Hash. # - # [Returns] (Hash<String, String>) Attribute names and values + # This is the union of Reader#attribute_hash and Reader#namespaces + # + # [Returns] + # (Hash<String, String>) Attribute names and values, and namespace prefixes and hrefs. def attributes - attrs_hash = attribute_nodes.each_with_object({}) do |node, hash| - hash[node.name] = node.to_s - end - ns = namespaces - attrs_hash.merge!(ns) if ns - attrs_hash + attribute_hash.merge(namespaces) end ### diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/metadata new/metadata --- old/metadata 2022-05-08 16:15:46.000000000 +0200 +++ new/metadata 2022-07-23 16:04:48.000000000 +0200 @@ -1,7 +1,7 @@ --- !ruby/object:Gem::Specification name: nokogiri version: !ruby/object:Gem::Version - version: 1.13.6 + version: 1.13.8 platform: ruby authors: - Mike Dalessio @@ -20,7 +20,7 @@ autorequire: bindir: bin cert_chain: [] -date: 2022-05-08 00:00:00.000000000 Z +date: 2022-07-23 00:00:00.000000000 Z dependencies: - !ruby/object:Gem::Dependency name: mini_portile2 @@ -138,16 +138,16 @@ name: rake-compiler-dock requirement: !ruby/object:Gem::Requirement requirements: - - - "~>" + - - '=' - !ruby/object:Gem::Version - version: '1.2' + version: 1.2.2 type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - - "~>" + - - '=' - !ruby/object:Gem::Version - version: '1.2' + version: 1.2.2 - !ruby/object:Gem::Dependency name: rdoc requirement: !ruby/object:Gem::Requirement @@ -182,20 +182,14 @@ requirements: - - "~>" - !ruby/object:Gem::Version - version: '1.28' - - - ">=" - - !ruby/object:Gem::Version - version: 1.28.2 + version: 1.30.1 type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - "~>" - !ruby/object:Gem::Version - version: '1.28' - - - ">=" - - !ruby/object:Gem::Version - version: 1.28.2 + version: 1.30.1 - !ruby/object:Gem::Dependency name: rubocop-minitest requirement: !ruby/object:Gem::Requirement @@ -242,16 +236,16 @@ name: rubocop-shopify requirement: !ruby/object:Gem::Requirement requirements: - - - "~>" + - - '=' - !ruby/object:Gem::Version - version: '2.3' + version: 2.5.0 type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - - "~>" + - - '=' - !ruby/object:Gem::Version - version: '2.3' + version: 2.5.0 - !ruby/object:Gem::Dependency name: ruby_memcheck requirement: !ruby/object:Gem::Requirement @@ -528,7 +522,7 @@ - !ruby/object:Gem::Version version: '0' requirements: [] -rubygems_version: 3.3.5 +rubygems_version: 3.3.7 signing_key: specification_version: 4 summary: Nokogiri (???) makes it easy and painless to work with XML and HTML from Ruby.