nokogiri 1.8.3 → 1.8.4

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of nokogiri might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e9cb90366d939c0faa58cf42e74ec4948e3ba422
4
- data.tar.gz: 970ab46f73afddcca4a8ab4651723214f80b6e7b
3
+ metadata.gz: 5f5da7cc1a450e2f45a78d1d505dbb335f4e7d93
4
+ data.tar.gz: 9608185d33a04d96176a26d94acb4d06d4ed6c47
5
5
  SHA512:
6
- metadata.gz: 527d7db935032c25b260a131d01bb3b2634ecd6a4edd144b57aa1d7185f54ca27deb7aa3aaccf077f4b291552307b9ec235e1beac1fd5909c365ac6389bb13d4
7
- data.tar.gz: 28a130a618bd4bc2ce69cf9c050017d7e60ef922916624a5cdf588b4a962119381bb73327f1c65c52629b47027a5f481f7f1378414e3f18cdb7f65f37a8124d5
6
+ metadata.gz: 61749f45c042c9c983e01a578b3a26e7a91a915d92b53481d369da507d7199873694a9ae3638a9e2c628877df2c1694f83ca7a3e4b82f0e60360fc2da8db1979
7
+ data.tar.gz: 15818dd921a0f9ba125f447e366153e67e2ed67a309ec76870facbb4a4196061c139e2e1818797c385220cdc8a3bd714b564e31bacc535e31c7969c8f1d70d07
@@ -1,3 +1,10 @@
1
+ # 1.8.4 / 2018-07-03
2
+
3
+ ## Bug fixes
4
+
5
+ * [MRI] Fix memory leak when creating nodes with namespaces. (Introduced in v1.5.7) [#1771]
6
+
7
+
1
8
  # 1.8.3 / 2018-06-16
2
9
 
3
10
  ## Security Notes
data/README.md CHANGED
@@ -6,6 +6,8 @@ Nokogiri (鋸) is an HTML, XML, SAX, and Reader parser. Among
6
6
  Nokogiri's many features is the ability to search documents via XPath
7
7
  or CSS3 selectors.
8
8
 
9
+ ## Links
10
+
9
11
  * http://nokogiri.org
10
12
  * [Installation Help](http://nokogiri.org/tutorials/installing_nokogiri.html)
11
13
  * [Tutorials](http://nokogiri.org)
@@ -30,7 +30,6 @@ typedef xmlNodePtr (*pivot_reparentee_func)(xmlNodePtr, xmlNodePtr);
30
30
  /* :nodoc: */
31
31
  static void relink_namespace(xmlNodePtr reparented)
32
32
  {
33
- xmlChar *name, *prefix;
34
33
  xmlNodePtr child;
35
34
  xmlNsPtr ns;
36
35
 
@@ -38,10 +37,16 @@ static void relink_namespace(xmlNodePtr reparented)
38
37
  reparented->type != XML_ELEMENT_NODE) { return; }
39
38
 
40
39
  if (reparented->ns == NULL || reparented->ns->prefix == NULL) {
40
+ xmlChar *name = 0, *prefix = 0;
41
+
41
42
  name = xmlSplitQName2(reparented->name, &prefix);
42
43
 
43
- if(reparented->type == XML_ATTRIBUTE_NODE) {
44
- if (prefix == NULL || strcmp((char*)prefix, XMLNS_PREFIX) == 0) { return; }
44
+ if (reparented->type == XML_ATTRIBUTE_NODE) {
45
+ if (prefix == NULL || strcmp((char*)prefix, XMLNS_PREFIX) == 0) {
46
+ xmlFree(name);
47
+ xmlFree(prefix);
48
+ return;
49
+ }
45
50
  }
46
51
 
47
52
  ns = xmlSearchNs(reparented->doc, reparented, prefix);
@@ -54,6 +59,9 @@ static void relink_namespace(xmlNodePtr reparented)
54
59
  xmlNodeSetName(reparented, name);
55
60
  xmlSetNs(reparented, ns);
56
61
  }
62
+
63
+ xmlFree(name);
64
+ xmlFree(prefix);
57
65
  }
58
66
 
59
67
  /* Avoid segv when relinking against unlinked nodes. */
@@ -71,10 +79,10 @@ static void relink_namespace(xmlNodePtr reparented)
71
79
 
72
80
  while (curr) {
73
81
  xmlNsPtr ns = xmlSearchNsByHref(
74
- reparented->doc,
75
- reparented->parent,
76
- curr->href
77
- );
82
+ reparented->doc,
83
+ reparented->parent,
84
+ curr->href
85
+ );
78
86
  /* If we find the namespace is already declared, remove it from this
79
87
  * definition list. */
80
88
  if (ns && ns != curr && xmlStrEqual(ns->prefix, curr->prefix)) {
@@ -143,10 +151,12 @@ static VALUE reparent_node_with(VALUE pivot_obj, VALUE reparentee_obj, pivot_rep
143
151
  xmlNodePtr reparentee, pivot, reparented, next_text, new_next_text, parent ;
144
152
  int original_ns_prefix_is_default = 0 ;
145
153
 
146
- if(!rb_obj_is_kind_of(reparentee_obj, cNokogiriXmlNode))
154
+ if(!rb_obj_is_kind_of(reparentee_obj, cNokogiriXmlNode)) {
147
155
  rb_raise(rb_eArgError, "node must be a Nokogiri::XML::Node");
148
- if(rb_obj_is_kind_of(reparentee_obj, cNokogiriXmlDocument))
156
+ }
157
+ if(rb_obj_is_kind_of(reparentee_obj, cNokogiriXmlDocument)) {
149
158
  rb_raise(rb_eArgError, "node must be a Nokogiri::XML::Node");
159
+ }
150
160
 
151
161
  Data_Get_Struct(reparentee_obj, xmlNode, reparentee);
152
162
  Data_Get_Struct(pivot_obj, xmlNode, pivot);
@@ -172,10 +182,10 @@ static VALUE reparent_node_with(VALUE pivot_obj, VALUE reparentee_obj, pivot_rep
172
182
  case XML_PI_NODE:
173
183
  case XML_COMMENT_NODE:
174
184
  case XML_DOCUMENT_TYPE_NODE:
175
- /*
176
- * The DOM specification says no to adding text-like nodes
177
- * directly to a document, but we allow it for compatibility.
178
- */
185
+ /*
186
+ * The DOM specification says no to adding text-like nodes
187
+ * directly to a document, but we allow it for compatibility.
188
+ */
179
189
  case XML_TEXT_NODE:
180
190
  case XML_CDATA_SECTION_NODE:
181
191
  case XML_ENTITY_REF_NODE:
@@ -368,9 +378,9 @@ static VALUE encode_special_chars(VALUE self, VALUE string)
368
378
 
369
379
  Data_Get_Struct(self, xmlNode, node);
370
380
  encoded = xmlEncodeSpecialChars(
371
- node->doc,
372
- (const xmlChar *)StringValueCStr(string)
373
- );
381
+ node->doc,
382
+ (const xmlChar *)StringValueCStr(string)
383
+ );
374
384
 
375
385
  encoded_str = NOKOGIRI_STR_NEW2(encoded);
376
386
  xmlFree(encoded);
@@ -400,17 +410,18 @@ static VALUE create_internal_subset(VALUE self, VALUE name, VALUE external_id, V
400
410
 
401
411
  doc = node->doc;
402
412
 
403
- if(xmlGetIntSubset(doc))
413
+ if(xmlGetIntSubset(doc)) {
404
414
  rb_raise(rb_eRuntimeError, "Document already has an internal subset");
415
+ }
405
416
 
406
417
  dtd = xmlCreateIntSubset(
407
- doc,
408
- NIL_P(name) ? NULL : (const xmlChar *)StringValueCStr(name),
409
- NIL_P(external_id) ? NULL : (const xmlChar *)StringValueCStr(external_id),
410
- NIL_P(system_id) ? NULL : (const xmlChar *)StringValueCStr(system_id)
411
- );
418
+ doc,
419
+ NIL_P(name) ? NULL : (const xmlChar *)StringValueCStr(name),
420
+ NIL_P(external_id) ? NULL : (const xmlChar *)StringValueCStr(external_id),
421
+ NIL_P(system_id) ? NULL : (const xmlChar *)StringValueCStr(system_id)
422
+ );
412
423
 
413
- if(!dtd) return Qnil;
424
+ if(!dtd) { return Qnil; }
414
425
 
415
426
  return Nokogiri_wrap_xml_node(Qnil, (xmlNodePtr)dtd);
416
427
  }
@@ -431,17 +442,18 @@ static VALUE create_external_subset(VALUE self, VALUE name, VALUE external_id, V
431
442
 
432
443
  doc = node->doc;
433
444
 
434
- if(doc->extSubset)
445
+ if(doc->extSubset) {
435
446
  rb_raise(rb_eRuntimeError, "Document already has an external subset");
447
+ }
436
448
 
437
449
  dtd = xmlNewDtd(
438
- doc,
439
- NIL_P(name) ? NULL : (const xmlChar *)StringValueCStr(name),
440
- NIL_P(external_id) ? NULL : (const xmlChar *)StringValueCStr(external_id),
441
- NIL_P(system_id) ? NULL : (const xmlChar *)StringValueCStr(system_id)
442
- );
450
+ doc,
451
+ NIL_P(name) ? NULL : (const xmlChar *)StringValueCStr(name),
452
+ NIL_P(external_id) ? NULL : (const xmlChar *)StringValueCStr(external_id),
453
+ NIL_P(system_id) ? NULL : (const xmlChar *)StringValueCStr(system_id)
454
+ );
443
455
 
444
- if(!dtd) return Qnil;
456
+ if(!dtd) { return Qnil; }
445
457
 
446
458
  return Nokogiri_wrap_xml_node(Qnil, (xmlNodePtr)dtd);
447
459
  }
@@ -460,12 +472,12 @@ static VALUE external_subset(VALUE self)
460
472
 
461
473
  Data_Get_Struct(self, xmlNode, node);
462
474
 
463
- if(!node->doc) return Qnil;
475
+ if(!node->doc) { return Qnil; }
464
476
 
465
477
  doc = node->doc;
466
478
  dtd = doc->extSubset;
467
479
 
468
- if(!dtd) return Qnil;
480
+ if(!dtd) { return Qnil; }
469
481
 
470
482
  return Nokogiri_wrap_xml_node(Qnil, (xmlNodePtr)dtd);
471
483
  }
@@ -484,12 +496,12 @@ static VALUE internal_subset(VALUE self)
484
496
 
485
497
  Data_Get_Struct(self, xmlNode, node);
486
498
 
487
- if(!node->doc) return Qnil;
499
+ if(!node->doc) { return Qnil; }
488
500
 
489
501
  doc = node->doc;
490
502
  dtd = xmlGetIntSubset(doc);
491
503
 
492
- if(!dtd) return Qnil;
504
+ if(!dtd) { return Qnil; }
493
505
 
494
506
  return Nokogiri_wrap_xml_node(Qnil, (xmlNodePtr)dtd);
495
507
  }
@@ -506,13 +518,14 @@ static VALUE duplicate_node(int argc, VALUE *argv, VALUE self)
506
518
  VALUE level;
507
519
  xmlNodePtr node, dup;
508
520
 
509
- if(rb_scan_args(argc, argv, "01", &level) == 0)
521
+ if(rb_scan_args(argc, argv, "01", &level) == 0) {
510
522
  level = INT2NUM((long)1);
523
+ }
511
524
 
512
525
  Data_Get_Struct(self, xmlNode, node);
513
526
 
514
527
  dup = xmlDocCopyNode(node, node->doc, (int)NUM2INT(level));
515
- if(dup == NULL) return Qnil;
528
+ if(dup == NULL) { return Qnil; }
516
529
 
517
530
  nokogiri_root_node(dup);
518
531
 
@@ -559,7 +572,7 @@ static VALUE next_sibling(VALUE self)
559
572
  Data_Get_Struct(self, xmlNode, node);
560
573
 
561
574
  sibling = node->next;
562
- if(!sibling) return Qnil;
575
+ if(!sibling) { return Qnil; }
563
576
 
564
577
  return Nokogiri_wrap_xml_node(Qnil, sibling) ;
565
578
  }
@@ -576,7 +589,7 @@ static VALUE previous_sibling(VALUE self)
576
589
  Data_Get_Struct(self, xmlNode, node);
577
590
 
578
591
  sibling = node->prev;
579
- if(!sibling) return Qnil;
592
+ if(!sibling) { return Qnil; }
580
593
 
581
594
  return Nokogiri_wrap_xml_node(Qnil, sibling);
582
595
  }
@@ -593,7 +606,7 @@ static VALUE next_element(VALUE self)
593
606
  Data_Get_Struct(self, xmlNode, node);
594
607
 
595
608
  sibling = xmlNextElementSibling(node);
596
- if(!sibling) return Qnil;
609
+ if(!sibling) { return Qnil; }
597
610
 
598
611
  return Nokogiri_wrap_xml_node(Qnil, sibling);
599
612
  }
@@ -613,10 +626,11 @@ static VALUE previous_element(VALUE self)
613
626
  * note that we don't use xmlPreviousElementSibling here because it's buggy pre-2.7.7.
614
627
  */
615
628
  sibling = node->prev;
616
- if(!sibling) return Qnil;
629
+ if(!sibling) { return Qnil; }
617
630
 
618
- while(sibling && sibling->type != XML_ELEMENT_NODE)
631
+ while(sibling && sibling->type != XML_ELEMENT_NODE) {
619
632
  sibling = sibling->prev;
633
+ }
620
634
 
621
635
  return sibling ? Nokogiri_wrap_xml_node(Qnil, sibling) : Qnil ;
622
636
  }
@@ -624,13 +638,13 @@ static VALUE previous_element(VALUE self)
624
638
  /* :nodoc: */
625
639
  static VALUE replace(VALUE self, VALUE new_node)
626
640
  {
627
- VALUE reparent = reparent_node_with(self, new_node, xmlReplaceNodeWrapper);
641
+ VALUE reparent = reparent_node_with(self, new_node, xmlReplaceNodeWrapper);
628
642
 
629
- xmlNodePtr pivot;
630
- Data_Get_Struct(self, xmlNode, pivot);
631
- nokogiri_root_node(pivot);
643
+ xmlNodePtr pivot;
644
+ Data_Get_Struct(self, xmlNode, pivot);
645
+ nokogiri_root_node(pivot);
632
646
 
633
- return reparent;
647
+ return reparent;
634
648
  }
635
649
 
636
650
  /*
@@ -654,7 +668,7 @@ static VALUE children(VALUE self)
654
668
 
655
669
  document = DOC_RUBY_OBJECT(node->doc);
656
670
 
657
- if(!child) return Nokogiri_wrap_xml_node_set(set, document);
671
+ if(!child) { return Nokogiri_wrap_xml_node_set(set, document); }
658
672
 
659
673
  child = child->next;
660
674
  while(NULL != child) {
@@ -693,7 +707,7 @@ static VALUE element_children(VALUE self)
693
707
 
694
708
  document = DOC_RUBY_OBJECT(node->doc);
695
709
 
696
- if(!child) return Nokogiri_wrap_xml_node_set(set, document);
710
+ if(!child) { return Nokogiri_wrap_xml_node_set(set, document); }
697
711
 
698
712
  child = xmlNextElementSibling(child);
699
713
  while(NULL != child) {
@@ -718,7 +732,7 @@ static VALUE child(VALUE self)
718
732
  Data_Get_Struct(self, xmlNode, node);
719
733
 
720
734
  child = node->children;
721
- if(!child) return Qnil;
735
+ if(!child) { return Qnil; }
722
736
 
723
737
  return Nokogiri_wrap_xml_node(Qnil, child);
724
738
  }
@@ -739,7 +753,7 @@ static VALUE first_element_child(VALUE self)
739
753
  Data_Get_Struct(self, xmlNode, node);
740
754
 
741
755
  child = xmlFirstElementChild(node);
742
- if(!child) return Qnil;
756
+ if(!child) { return Qnil; }
743
757
 
744
758
  return Nokogiri_wrap_xml_node(Qnil, child);
745
759
  }
@@ -760,7 +774,7 @@ static VALUE last_element_child(VALUE self)
760
774
  Data_Get_Struct(self, xmlNode, node);
761
775
 
762
776
  child = xmlLastElementChild(node);
763
- if(!child) return Qnil;
777
+ if(!child) { return Qnil; }
764
778
 
765
779
  return Nokogiri_wrap_xml_node(Qnil, child);
766
780
  }
@@ -775,8 +789,9 @@ static VALUE key_eh(VALUE self, VALUE attribute)
775
789
  {
776
790
  xmlNodePtr node;
777
791
  Data_Get_Struct(self, xmlNode, node);
778
- if(xmlHasProp(node, (xmlChar *)StringValueCStr(attribute)))
792
+ if(xmlHasProp(node, (xmlChar *)StringValueCStr(attribute))) {
779
793
  return Qtrue;
794
+ }
780
795
  return Qfalse;
781
796
  }
782
797
 
@@ -791,8 +806,9 @@ static VALUE namespaced_key_eh(VALUE self, VALUE attribute, VALUE namespace)
791
806
  xmlNodePtr node;
792
807
  Data_Get_Struct(self, xmlNode, node);
793
808
  if(xmlHasNsProp(node, (xmlChar *)StringValueCStr(attribute),
794
- NIL_P(namespace) ? NULL : (xmlChar *)StringValueCStr(namespace)))
809
+ NIL_P(namespace) ? NULL : (xmlChar *)StringValueCStr(namespace))) {
795
810
  return Qtrue;
811
+ }
796
812
  return Qfalse;
797
813
  }
798
814
 
@@ -814,8 +830,9 @@ static VALUE set(VALUE self, VALUE property, VALUE value)
814
830
  *
815
831
  * We can avoid this by unlinking these nodes first.
816
832
  */
817
- if (node->type != XML_ELEMENT_NODE)
833
+ if (node->type != XML_ELEMENT_NODE) {
818
834
  return(Qnil);
835
+ }
819
836
  prop = xmlHasProp(node, (xmlChar *)StringValueCStr(property));
820
837
  if (prop && prop->children) {
821
838
  for (cur = prop->children; cur; cur = cur->next) {
@@ -827,7 +844,7 @@ static VALUE set(VALUE self, VALUE property, VALUE value)
827
844
  }
828
845
 
829
846
  xmlSetProp(node, (xmlChar *)StringValueCStr(property),
830
- (xmlChar *)StringValueCStr(value));
847
+ (xmlChar *)StringValueCStr(value));
831
848
 
832
849
  return value;
833
850
  }
@@ -847,7 +864,7 @@ static VALUE get(VALUE self, VALUE rattribute)
847
864
  xmlChar *attribute, *attr_name, *prefix;
848
865
  xmlNsPtr ns;
849
866
 
850
- if (NIL_P(rattribute)) return Qnil;
867
+ if (NIL_P(rattribute)) { return Qnil; }
851
868
 
852
869
  Data_Get_Struct(self, xmlNode, node);
853
870
  attribute = xmlCharStrdup(StringValueCStr(rattribute));
@@ -871,7 +888,7 @@ static VALUE get(VALUE self, VALUE rattribute)
871
888
  }
872
889
 
873
890
  xmlFree((void *)attribute);
874
- if (!value) return Qnil;
891
+ if (!value) { return Qnil; }
875
892
 
876
893
  rvalue = NOKOGIRI_STR_NEW2(value);
877
894
  xmlFree((void *)value);
@@ -892,8 +909,9 @@ static VALUE set_namespace(VALUE self, VALUE namespace)
892
909
 
893
910
  Data_Get_Struct(self, xmlNode, node);
894
911
 
895
- if(!NIL_P(namespace))
912
+ if(!NIL_P(namespace)) {
896
913
  Data_Get_Struct(namespace, xmlNs, ns);
914
+ }
897
915
 
898
916
  xmlSetNs(node, ns);
899
917
 
@@ -913,7 +931,7 @@ static VALUE attr(VALUE self, VALUE name)
913
931
  Data_Get_Struct(self, xmlNode, node);
914
932
  prop = xmlHasProp(node, (xmlChar *)StringValueCStr(name));
915
933
 
916
- if(! prop) return Qnil;
934
+ if(! prop) { return Qnil; }
917
935
  return Nokogiri_wrap_xml_node(Qnil, (xmlNodePtr)prop);
918
936
  }
919
937
 
@@ -929,9 +947,9 @@ static VALUE attribute_with_ns(VALUE self, VALUE name, VALUE namespace)
929
947
  xmlAttrPtr prop;
930
948
  Data_Get_Struct(self, xmlNode, node);
931
949
  prop = xmlHasNsProp(node, (xmlChar *)StringValueCStr(name),
932
- NIL_P(namespace) ? NULL : (xmlChar *)StringValueCStr(namespace));
950
+ NIL_P(namespace) ? NULL : (xmlChar *)StringValueCStr(namespace));
933
951
 
934
- if(! prop) return Qnil;
952
+ if(! prop) { return Qnil; }
935
953
  return Nokogiri_wrap_xml_node(Qnil, (xmlNodePtr)prop);
936
954
  }
937
955
 
@@ -943,16 +961,16 @@ static VALUE attribute_with_ns(VALUE self, VALUE name, VALUE namespace)
943
961
  */
944
962
  static VALUE attribute_nodes(VALUE self)
945
963
  {
946
- /* this code in the mode of xmlHasProp() */
947
- xmlNodePtr node;
948
- VALUE attr;
964
+ /* this code in the mode of xmlHasProp() */
965
+ xmlNodePtr node;
966
+ VALUE attr;
949
967
 
950
- Data_Get_Struct(self, xmlNode, node);
968
+ Data_Get_Struct(self, xmlNode, node);
951
969
 
952
- attr = rb_ary_new();
953
- Nokogiri_xml_node_properties(node, attr);
970
+ attr = rb_ary_new();
971
+ Nokogiri_xml_node_properties(node, attr);
954
972
 
955
- return attr ;
973
+ return attr ;
956
974
  }
957
975
 
958
976
 
@@ -965,13 +983,14 @@ static VALUE attribute_nodes(VALUE self)
965
983
  */
966
984
  static VALUE namespace(VALUE self)
967
985
  {
968
- xmlNodePtr node ;
969
- Data_Get_Struct(self, xmlNode, node);
986
+ xmlNodePtr node ;
987
+ Data_Get_Struct(self, xmlNode, node);
970
988
 
971
- if (node->ns)
972
- return Nokogiri_wrap_xml_namespace(node->doc, node->ns);
989
+ if (node->ns) {
990
+ return Nokogiri_wrap_xml_namespace(node->doc, node->ns);
991
+ }
973
992
 
974
- return Qnil ;
993
+ return Qnil ;
975
994
  }
976
995
 
977
996
  /*
@@ -993,7 +1012,7 @@ static VALUE namespace_definitions(VALUE self)
993
1012
 
994
1013
  ns = node->nsDef;
995
1014
 
996
- if(!ns) return list;
1015
+ if(!ns) { return list; }
997
1016
 
998
1017
  while(NULL != ns) {
999
1018
  rb_ary_push(list, Nokogiri_wrap_xml_namespace(node->doc, ns));
@@ -1024,7 +1043,7 @@ static VALUE namespace_scopes(VALUE self)
1024
1043
  list = rb_ary_new();
1025
1044
  ns_list = xmlGetNsList(node->doc, node);
1026
1045
 
1027
- if(!ns_list) return list;
1046
+ if(!ns_list) { return list; }
1028
1047
 
1029
1048
  for (j = 0 ; ns_list[j] != NULL ; ++j) {
1030
1049
  rb_ary_push(list, Nokogiri_wrap_xml_namespace(node->doc, ns_list[j]));
@@ -1154,7 +1173,7 @@ static VALUE get_parent(VALUE self)
1154
1173
  Data_Get_Struct(self, xmlNode, node);
1155
1174
 
1156
1175
  parent = node->parent;
1157
- if(!parent) return Qnil;
1176
+ if(!parent) { return Qnil; }
1158
1177
 
1159
1178
  return Nokogiri_wrap_xml_node(Qnil, parent) ;
1160
1179
  }
@@ -1183,8 +1202,9 @@ static VALUE get_name(VALUE self)
1183
1202
  {
1184
1203
  xmlNodePtr node;
1185
1204
  Data_Get_Struct(self, xmlNode, node);
1186
- if(node->name)
1205
+ if(node->name) {
1187
1206
  return NOKOGIRI_STR_NEW2(node->name);
1207
+ }
1188
1208
  return Qnil;
1189
1209
  }
1190
1210
 
@@ -1227,12 +1247,13 @@ static VALUE add_previous_sibling(VALUE self, VALUE new_sibling)
1227
1247
  * Write this Node to +io+ with +encoding+ and +options+
1228
1248
  */
1229
1249
  static VALUE native_write_to(
1230
- VALUE self,
1231
- VALUE io,
1232
- VALUE encoding,
1233
- VALUE indent_string,
1234
- VALUE options
1235
- ) {
1250
+ VALUE self,
1251
+ VALUE io,
1252
+ VALUE encoding,
1253
+ VALUE indent_string,
1254
+ VALUE options
1255
+ )
1256
+ {
1236
1257
  xmlNodePtr node;
1237
1258
  const char * before_indent;
1238
1259
  xmlSaveCtxtPtr savectx;
@@ -1246,12 +1267,12 @@ static VALUE native_write_to(
1246
1267
  xmlTreeIndentString = StringValueCStr(indent_string);
1247
1268
 
1248
1269
  savectx = xmlSaveToIO(
1249
- (xmlOutputWriteCallback)io_write_callback,
1250
- (xmlOutputCloseCallback)io_close_callback,
1251
- (void *)io,
1252
- RTEST(encoding) ? StringValueCStr(encoding) : NULL,
1253
- (int)NUM2INT(options)
1254
- );
1270
+ (xmlOutputWriteCallback)io_write_callback,
1271
+ (xmlOutputCloseCallback)io_close_callback,
1272
+ (void *)io,
1273
+ RTEST(encoding) ? StringValueCStr(encoding) : NULL,
1274
+ (int)NUM2INT(options)
1275
+ );
1255
1276
 
1256
1277
  xmlSaveTree(savectx, node);
1257
1278
  xmlSaveClose(savectx);
@@ -1294,25 +1315,25 @@ static VALUE add_namespace_definition(VALUE self, VALUE prefix, VALUE href)
1294
1315
  namespacee = node ;
1295
1316
 
1296
1317
  ns = xmlSearchNs(
1297
- node->doc,
1298
- node,
1299
- (const xmlChar *)(NIL_P(prefix) ? NULL : StringValueCStr(prefix))
1300
- );
1318
+ node->doc,
1319
+ node,
1320
+ (const xmlChar *)(NIL_P(prefix) ? NULL : StringValueCStr(prefix))
1321
+ );
1301
1322
 
1302
1323
  if(!ns) {
1303
1324
  if (node->type != XML_ELEMENT_NODE) {
1304
1325
  namespacee = node->parent;
1305
1326
  }
1306
1327
  ns = xmlNewNs(
1307
- namespacee,
1308
- (const xmlChar *)StringValueCStr(href),
1309
- (const xmlChar *)(NIL_P(prefix) ? NULL : StringValueCStr(prefix))
1310
- );
1328
+ namespacee,
1329
+ (const xmlChar *)StringValueCStr(href),
1330
+ (const xmlChar *)(NIL_P(prefix) ? NULL : StringValueCStr(prefix))
1331
+ );
1311
1332
  }
1312
1333
 
1313
- if (!ns) return Qnil ;
1334
+ if (!ns) { return Qnil ; }
1314
1335
 
1315
- if(NIL_P(prefix) || node != namespacee) xmlSetNs(node, ns);
1336
+ if(NIL_P(prefix) || node != namespacee) { xmlSetNs(node, ns); }
1316
1337
 
1317
1338
  return Nokogiri_wrap_xml_namespace(node->doc, ns);
1318
1339
  }
@@ -1341,12 +1362,12 @@ static VALUE new(int argc, VALUE *argv, VALUE klass)
1341
1362
  nokogiri_root_node(node);
1342
1363
 
1343
1364
  rb_node = Nokogiri_wrap_xml_node(
1344
- klass == cNokogiriXmlNode ? (VALUE)NULL : klass,
1345
- node
1346
- );
1365
+ klass == cNokogiriXmlNode ? (VALUE)NULL : klass,
1366
+ node
1367
+ );
1347
1368
  rb_obj_call_init(rb_node, argc, argv);
1348
1369
 
1349
- if(rb_block_given_p()) rb_yield(rb_node);
1370
+ if(rb_block_given_p()) { rb_yield(rb_node); }
1350
1371
 
1351
1372
  return rb_node;
1352
1373
  }
@@ -1411,10 +1432,11 @@ static VALUE process_xincludes(VALUE self, VALUE options)
1411
1432
  xmlErrorPtr error;
1412
1433
 
1413
1434
  error = xmlGetLastError();
1414
- if(error)
1435
+ if(error) {
1415
1436
  rb_exc_raise(Nokogiri_wrap_xml_syntax_error(error));
1416
- else
1437
+ } else {
1417
1438
  rb_raise(rb_eRuntimeError, "Could not perform xinclude substitution");
1439
+ }
1418
1440
  }
1419
1441
 
1420
1442
  return self;
@@ -1424,101 +1446,104 @@ static VALUE process_xincludes(VALUE self, VALUE options)
1424
1446
  /* TODO: DOCUMENT ME */
1425
1447
  static VALUE in_context(VALUE self, VALUE _str, VALUE _options)
1426
1448
  {
1427
- xmlNodePtr node, list = 0, tmp, child_iter, node_children, doc_children;
1428
- xmlNodeSetPtr set;
1429
- xmlParserErrors error;
1430
- VALUE doc, err;
1431
- int doc_is_empty;
1449
+ xmlNodePtr node, list = 0, tmp, child_iter, node_children, doc_children;
1450
+ xmlNodeSetPtr set;
1451
+ xmlParserErrors error;
1452
+ VALUE doc, err;
1453
+ int doc_is_empty;
1432
1454
 
1433
- Data_Get_Struct(self, xmlNode, node);
1455
+ Data_Get_Struct(self, xmlNode, node);
1434
1456
 
1435
- doc = DOC_RUBY_OBJECT(node->doc);
1436
- err = rb_iv_get(doc, "@errors");
1437
- doc_is_empty = (node->doc->children == NULL) ? 1 : 0;
1438
- node_children = node->children;
1439
- doc_children = node->doc->children;
1457
+ doc = DOC_RUBY_OBJECT(node->doc);
1458
+ err = rb_iv_get(doc, "@errors");
1459
+ doc_is_empty = (node->doc->children == NULL) ? 1 : 0;
1460
+ node_children = node->children;
1461
+ doc_children = node->doc->children;
1440
1462
 
1441
- xmlSetStructuredErrorFunc((void *)err, Nokogiri_error_array_pusher);
1463
+ xmlSetStructuredErrorFunc((void *)err, Nokogiri_error_array_pusher);
1442
1464
 
1443
- /* Twiddle global variable because of a bug in libxml2.
1444
- * http://git.gnome.org/browse/libxml2/commit/?id=e20fb5a72c83cbfc8e4a8aa3943c6be8febadab7
1445
- */
1465
+ /* Twiddle global variable because of a bug in libxml2.
1466
+ * http://git.gnome.org/browse/libxml2/commit/?id=e20fb5a72c83cbfc8e4a8aa3943c6be8febadab7
1467
+ */
1446
1468
  #ifndef HTML_PARSE_NOIMPLIED
1447
- htmlHandleOmittedElem(0);
1469
+ htmlHandleOmittedElem(0);
1448
1470
  #endif
1449
1471
 
1450
- /* This function adds a fake node to the child of +node+. If the parser
1451
- * does not exit cleanly with XML_ERR_OK, the list is freed. This can
1452
- * leave the child pointers in a bad state if they were originally empty.
1453
- *
1454
- * http://git.gnome.org/browse/libxml2/tree/parser.c#n13177
1455
- * */
1456
- error = xmlParseInNodeContext(node, StringValuePtr(_str),
1457
- (int)RSTRING_LEN(_str),
1458
- (int)NUM2INT(_options), &list);
1459
-
1460
- /* xmlParseInNodeContext should not mutate the original document or node,
1461
- * so reassigning these pointers should be OK. The reason we're reassigning
1462
- * is because if there were errors, it's possible for the child pointers
1463
- * to be manipulated. */
1464
- if (error != XML_ERR_OK) {
1465
- node->doc->children = doc_children;
1466
- node->children = node_children;
1467
- }
1472
+ /* This function adds a fake node to the child of +node+. If the parser
1473
+ * does not exit cleanly with XML_ERR_OK, the list is freed. This can
1474
+ * leave the child pointers in a bad state if they were originally empty.
1475
+ *
1476
+ * http://git.gnome.org/browse/libxml2/tree/parser.c#n13177
1477
+ * */
1478
+ error = xmlParseInNodeContext(node, StringValuePtr(_str),
1479
+ (int)RSTRING_LEN(_str),
1480
+ (int)NUM2INT(_options), &list);
1481
+
1482
+ /* xmlParseInNodeContext should not mutate the original document or node,
1483
+ * so reassigning these pointers should be OK. The reason we're reassigning
1484
+ * is because if there were errors, it's possible for the child pointers
1485
+ * to be manipulated. */
1486
+ if (error != XML_ERR_OK) {
1487
+ node->doc->children = doc_children;
1488
+ node->children = node_children;
1489
+ }
1468
1490
 
1469
- /* make sure parent/child pointers are coherent so an unlink will work
1470
- * properly (#331)
1471
- */
1472
- child_iter = node->doc->children ;
1473
- while (child_iter) {
1474
- if (child_iter->parent != (xmlNodePtr)node->doc)
1475
- child_iter->parent = (xmlNodePtr)node->doc;
1476
- child_iter = child_iter->next;
1491
+ /* make sure parent/child pointers are coherent so an unlink will work
1492
+ * properly (#331)
1493
+ */
1494
+ child_iter = node->doc->children ;
1495
+ while (child_iter) {
1496
+ if (child_iter->parent != (xmlNodePtr)node->doc) {
1497
+ child_iter->parent = (xmlNodePtr)node->doc;
1477
1498
  }
1499
+ child_iter = child_iter->next;
1500
+ }
1478
1501
 
1479
1502
  #ifndef HTML_PARSE_NOIMPLIED
1480
- htmlHandleOmittedElem(1);
1503
+ htmlHandleOmittedElem(1);
1481
1504
  #endif
1482
1505
 
1483
- xmlSetStructuredErrorFunc(NULL, NULL);
1484
-
1485
- /* Workaround for a libxml2 bug where a parsing error may leave a broken
1486
- * node reference in node->doc->children.
1487
- * This workaround is limited to when a parse error occurs, the document
1488
- * went from having no children to having children, and the context node is
1489
- * part of a document fragment.
1490
- * https://bugzilla.gnome.org/show_bug.cgi?id=668155
1491
- */
1492
- if (error != XML_ERR_OK && doc_is_empty && node->doc->children != NULL) {
1493
- child_iter = node;
1494
- while (child_iter->parent)
1495
- child_iter = child_iter->parent;
1506
+ xmlSetStructuredErrorFunc(NULL, NULL);
1496
1507
 
1497
- if (child_iter->type == XML_DOCUMENT_FRAG_NODE)
1498
- node->doc->children = NULL;
1508
+ /* Workaround for a libxml2 bug where a parsing error may leave a broken
1509
+ * node reference in node->doc->children.
1510
+ * This workaround is limited to when a parse error occurs, the document
1511
+ * went from having no children to having children, and the context node is
1512
+ * part of a document fragment.
1513
+ * https://bugzilla.gnome.org/show_bug.cgi?id=668155
1514
+ */
1515
+ if (error != XML_ERR_OK && doc_is_empty && node->doc->children != NULL) {
1516
+ child_iter = node;
1517
+ while (child_iter->parent) {
1518
+ child_iter = child_iter->parent;
1499
1519
  }
1500
1520
 
1501
- /* FIXME: This probably needs to handle more constants... */
1502
- switch (error) {
1503
- case XML_ERR_INTERNAL_ERROR:
1504
- case XML_ERR_NO_MEMORY:
1505
- rb_raise(rb_eRuntimeError, "error parsing fragment (%d)", error);
1506
- break;
1507
- default:
1508
- break;
1521
+ if (child_iter->type == XML_DOCUMENT_FRAG_NODE) {
1522
+ node->doc->children = NULL;
1509
1523
  }
1524
+ }
1510
1525
 
1511
- set = xmlXPathNodeSetCreate(NULL);
1526
+ /* FIXME: This probably needs to handle more constants... */
1527
+ switch (error) {
1528
+ case XML_ERR_INTERNAL_ERROR:
1529
+ case XML_ERR_NO_MEMORY:
1530
+ rb_raise(rb_eRuntimeError, "error parsing fragment (%d)", error);
1531
+ break;
1532
+ default:
1533
+ break;
1534
+ }
1512
1535
 
1513
- while (list) {
1514
- tmp = list->next;
1515
- list->next = NULL;
1516
- xmlXPathNodeSetAddUnique(set, list);
1517
- nokogiri_root_node(list);
1518
- list = tmp;
1519
- }
1536
+ set = xmlXPathNodeSetCreate(NULL);
1537
+
1538
+ while (list) {
1539
+ tmp = list->next;
1540
+ list->next = NULL;
1541
+ xmlXPathNodeSetAddUnique(set, list);
1542
+ nokogiri_root_node(list);
1543
+ list = tmp;
1544
+ }
1520
1545
 
1521
- return Nokogiri_wrap_xml_node_set(set, doc);
1546
+ return Nokogiri_wrap_xml_node_set(set, doc);
1522
1547
  }
1523
1548
 
1524
1549
 
@@ -1533,22 +1558,23 @@ VALUE Nokogiri_wrap_xml_node(VALUE klass, xmlNodePtr node)
1533
1558
 
1534
1559
  assert(node);
1535
1560
 
1536
- if(node->type == XML_DOCUMENT_NODE || node->type == XML_HTML_DOCUMENT_NODE)
1537
- return DOC_RUBY_OBJECT(node->doc);
1561
+ if(node->type == XML_DOCUMENT_NODE || node->type == XML_HTML_DOCUMENT_NODE) {
1562
+ return DOC_RUBY_OBJECT(node->doc);
1563
+ }
1538
1564
 
1539
1565
  /* It's OK if the node doesn't have a fully-realized document (as in XML::Reader). */
1540
1566
  /* see https://github.com/sparklemotion/nokogiri/issues/95 */
1541
1567
  /* and https://github.com/sparklemotion/nokogiri/issues/439 */
1542
1568
  doc = node->doc;
1543
- if (doc->type == XML_DOCUMENT_FRAG_NODE) doc = doc->doc;
1569
+ if (doc->type == XML_DOCUMENT_FRAG_NODE) { doc = doc->doc; }
1544
1570
  node_has_a_document = DOC_RUBY_OBJECT_TEST(doc);
1545
1571
 
1546
- if(node->_private && node_has_a_document)
1572
+ if(node->_private && node_has_a_document) {
1547
1573
  return (VALUE)node->_private;
1574
+ }
1548
1575
 
1549
1576
  if(!RTEST(klass)) {
1550
- switch(node->type)
1551
- {
1577
+ switch(node->type) {
1552
1578
  case XML_ELEMENT_NODE:
1553
1579
  klass = cNokogiriXmlElement;
1554
1580
  break;
@@ -1,6 +1,6 @@
1
1
  module Nokogiri
2
2
  # The version of Nokogiri you are using
3
- VERSION = '1.8.3'
3
+ VERSION = '1.8.4'
4
4
 
5
5
  class VersionInfo # :nodoc:
6
6
  def jruby?
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nokogiri
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.3
4
+ version: 1.8.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Patterson
@@ -14,7 +14,7 @@ authors:
14
14
  autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
- date: 2018-06-16 00:00:00.000000000 Z
17
+ date: 2018-07-03 00:00:00.000000000 Z
18
18
  dependencies:
19
19
  - !ruby/object:Gem::Dependency
20
20
  name: mini_portile2
@@ -216,19 +216,6 @@ description: |-
216
216
  Nokogiri (鋸) is an HTML, XML, SAX, and Reader parser. Among
217
217
  Nokogiri's many features is the ability to search documents via XPath
218
218
  or CSS3 selectors.
219
-
220
- * http://nokogiri.org
221
- * [Installation Help](http://nokogiri.org/tutorials/installing_nokogiri.html)
222
- * [Tutorials](http://nokogiri.org)
223
- * [GitHub](https://github.com/sparklemotion/nokogiri)
224
- * [Mailing List](https://groups.google.com/group/nokogiri-talk)
225
- * [Bug Reports](https://github.com/sparklemotion/nokogiri/issues)
226
- * [Chat/Gitter](https://gitter.im/sparklemotion/nokogiri)
227
-
228
- [![Concourse CI](https://ci.nokogiri.org/api/v1/teams/nokogiri-core/pipelines/nokogiri/jobs/ruby-2.4-system/badge)](https://ci.nokogiri.org/teams/nokogiri-core/pipelines/nokogiri?groups=master)
229
- [![Code Climate](https://codeclimate.com/github/sparklemotion/nokogiri.svg)](https://codeclimate.com/github/sparklemotion/nokogiri)
230
- [![Version Eye](https://www.versioneye.com/ruby/nokogiri/badge.png)](https://www.versioneye.com/ruby/nokogiri)
231
- [![Join the chat at https://gitter.im/sparklemotion/nokogiri](https://badges.gitter.im/sparklemotion/nokogiri.svg)](https://gitter.im/sparklemotion/nokogiri?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
232
219
  email:
233
220
  - aaronp@rubyforge.org
234
221
  - mike.dalessio@gmail.com