Skip to content

Commit 769faec

Browse files
authoredAug 11, 2023
backport updates and fixes to v1.15.x (#2953)
**What problem is this PR intended to solve?** Backporting changes from: - #2927 - #2924 - #2951
2 parents 0d545ac + 8460bfe commit 769faec

File tree

10 files changed

+45
-13
lines changed

10 files changed

+45
-13
lines changed
 

‎.github/ISSUE_TEMPLATE/1-bug-report.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Here's an example of how you might structure such a script:
3232
require 'nokogiri'
3333
require 'minitest/autorun'
3434
35-
class Test < MiniTest::Spec
35+
class Test < Minitest::Spec
3636
describe "Node#css" do
3737
it "should find a div using chained classes" do
3838
html = <<~HEREDOC

‎.github/workflows/downstream.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
command: "bundle exec rake spec"
4848
- url: https://github.com/SAML-Toolkits/ruby-saml
4949
name: ruby-saml
50-
command: "bundle exec rake test"
50+
command: "bundle exec rake test MT_COMPAT=t"
5151
# - url: https://github.com/instructure/nokogiri-xmlsec-instructure
5252
# name: nokogiri-xmlsec-instructure
5353
# precommand: "apt install -y libxmlsec1-dev"

‎CHANGELOG.md

+13
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,19 @@ Nokogiri follows [Semantic Versioning](https://semver.org/), please see the [REA
44

55
---
66

7+
## next / unreleased
8+
9+
### Dependencies
10+
11+
* [CRuby] Vendored libxml2 is updated to v2.11.5 from v2.11.4. For details please see https://gitlab.gnome.org/GNOME/libxml2/-/releases/v2.11.5
12+
13+
14+
### Fixed
15+
16+
* Fixed a typo in a HTML5 parser error message. [[#2927](https://github.com/sparklemotion/nokogiri/issues/2927)] (Thanks, [@anishathalye](https://github.com/anishathalye)!)
17+
* [CRuby] `ObjectSpace.memsize_of` is now safe to call on `Document`s with complex DTDs. In previous versions, this debugging method could result in a segfault. [[#2923](https://github.com/sparklemotion/nokogiri/issues/2923), [#2924](https://github.com/sparklemotion/nokogiri/issues/2924)]
18+
19+
720
## 1.15.3 / 2023-07-05
821

922
### Fixed

‎CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ Note that `rake test` does not compile the native extension, and this is intenti
124124
bundle exec rake compile test
125125
```
126126

127-
To run a focused test, use MiniTest's `TESTOPTS`:
127+
To run a focused test, use Minitest's `TESTOPTS`:
128128

129129
``` sh
130130
bundle exec rake compile test TESTOPTS="-n/test_last_element_child/"

‎dependencies.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
libxml2:
2-
version: "2.11.4"
3-
sha256: "737e1d7f8ab3f139729ca13a2494fd17bf30ddb4b7a427cf336252cab57f57f7"
4-
# sha-256 hash provided in https://download.gnome.org/sources/libxml2/2.11/libxml2-2.11.4.sha256sum
2+
version: "2.11.5"
3+
sha256: "3727b078c360ec69fa869de14bd6f75d7ee8d36987b071e6928d4720a28df3a6"
4+
# sha-256 hash provided in https://download.gnome.org/sources/libxml2/2.11/libxml2-2.11.5.sha256sum
55

66
libxslt:
77
version: "1.1.38"

‎ext/nokogiri/xml_document.c

+6-2
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,15 @@ memsize_node(const xmlNodePtr node)
100100
{
101101
/* note we don't count namespace definitions, just going for a good-enough number here */
102102
xmlNodePtr child;
103+
xmlAttrPtr property;
103104
size_t memsize = 0;
104105

105106
memsize += xmlStrlen(node->name);
106-
for (child = (xmlNodePtr)node->properties; child; child = child->next) {
107-
memsize += sizeof(xmlAttr) + memsize_node(child);
107+
108+
if (node->type == XML_ELEMENT_NODE) {
109+
for (property = node->properties; property; property = property->next) {
110+
memsize += sizeof(xmlAttr) + memsize_node((xmlNodePtr)property);
111+
}
108112
}
109113
if (node->type == XML_TEXT_NODE) {
110114
memsize += xmlStrlen(node->content);

‎gumbo-parser/src/error.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ static void handle_parser_error (
357357
print_tag_stack(error, output);
358358
return;
359359
case GUMBO_TOKEN_END_TAG:
360-
print_message(output, "Eng tag '%s' isn't allowed here.",
360+
print_message(output, "End tag '%s' isn't allowed here.",
361361
gumbo_normalized_tagname(error->input_tag));
362362
print_tag_stack(error, output);
363363
return;

‎suppressions/ruby.supp

+2-2
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898
fun:evaluate
9999
}
100100
{
101-
TODO
101+
https://github.com/sparklemotion/nokogiri/actions/runs/5354163940/jobs/9710862134
102102
# 240 (120 direct, 120 indirect) bytes in 1 blocks are definitely lost in loss record 28,980 of 37,883
103103
# *xmlNewNodeEatName (tree.c:2299)
104104
# *xmlNewDocNodeEatName (tree.c:2374)
@@ -117,7 +117,7 @@
117117
fun:xmlNewNodeEatName
118118
fun:xmlNewDocNodeEatName
119119
fun:xmlSAX2StartElementNs
120-
fun:xmlParseStartTag2
120+
fun:xmlParseStartTag*
121121
fun:xmlParseElementStart
122122
fun:xmlParseContentInternal
123123
fun:xmlParseElement

‎test/helper.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ class TestBenchmark < Minitest::BenchSpec
128128
end
129129

130130
# rubocop:disable Style/ClassVars
131-
class TestCase < MiniTest::Spec
131+
class TestCase < Minitest::Spec
132132
include TestBase
133133

134134
COMPACT_EVERY = 20
@@ -272,7 +272,7 @@ def assert_not_send(send_ary, m = nil)
272272
def pending(msg)
273273
begin
274274
yield
275-
rescue MiniTest::Assertion
275+
rescue Minitest::Assertion
276276
skip("pending #{msg} [#{caller(2..2).first}]")
277277
end
278278
flunk("pending test unexpectedly passed: #{msg} [#{caller(1..1).first}]")

‎test/test_memory_leak.rb

+15
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,21 @@ def test_object_space_memsize_of
313313
assert(bigger_name_size > base_size, "longer tags should increase memsize")
314314
end
315315

316+
def test_object_space_memsize_with_dtd
317+
# https://github.com/sparklemotion/nokogiri/issues/2923
318+
require "objspace"
319+
skip("memsize_of not defined") unless ObjectSpace.respond_to?(:memsize_of)
320+
321+
doc = Nokogiri::XML(<<~XML)
322+
<?xml version="1.0"?>
323+
<!DOCTYPE staff PUBLIC "staff.dtd" [
324+
<!ATTLIST payment type CDATA "check">
325+
]>
326+
<staff></staff>
327+
XML
328+
ObjectSpace.memsize_of(doc) # assert_does_not_crash
329+
end
330+
316331
module MemInfo
317332
# from https://stackoverflow.com/questions/7220896/get-current-ruby-process-memory-usage
318333
# this is only going to work on linux

0 commit comments

Comments
 (0)