Skip to content
This repository has been archived by the owner on Aug 28, 2020. It is now read-only.

Commit

Permalink
Merge branch '693-nonet'
Browse files Browse the repository at this point in the history
  • Loading branch information
flavorjones committed Jun 8, 2012
2 parents 82091df + a5770a0 commit 5998563
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.ja.rdoc
Expand Up @@ -10,6 +10,9 @@

* Segmentation fault when creating a comment node for a DocumentFragment. #677, #678.
* Treat '.' as xpath in at() and search(). #690
* [MRI] [Security] Default parse options for XML documents were
changed to not make network connections during document parsing,
to avoid XXE vulnerability. #693


== 1.5.3 / 2012-06-01
Expand Down
4 changes: 3 additions & 1 deletion CHANGELOG.rdoc
Expand Up @@ -10,7 +10,9 @@

* Segmentation fault when creating a comment node for a DocumentFragment. #677, #678.
* Treat '.' as xpath in at() and search(). #690

* [MRI] [Security] Default parse options for XML documents were
changed to not make network connections during document parsing,
to avoid XXE vulnerability. #693

== 1.5.3 / 2012-06-01

Expand Down
7 changes: 6 additions & 1 deletion lib/nokogiri/xml/parse_options.rb
Expand Up @@ -47,7 +47,7 @@ class ParseOptions
HUGE = 1 << 19

# the default options used for parsing XML documents
DEFAULT_XML = RECOVER
DEFAULT_XML = RECOVER | NONET
# the default options used for parsing HTML documents
DEFAULT_HTML = RECOVER | NOERROR | NOWARNING | NONET

Expand All @@ -64,6 +64,11 @@ def #{constant.downcase}
self
end
def no#{constant.downcase}
@options &= ~#{constant}
self
end
def #{constant.downcase}?
#{constant} & @options == #{constant}
end
Expand Down
12 changes: 12 additions & 0 deletions test/xml/test_parse_options.rb
Expand Up @@ -35,6 +35,18 @@ def test_new_with_argument
assert_equal 1 << 1, options.options
end

def test_unsetting
options = Nokogiri::XML::ParseOptions.new Nokogiri::XML::ParseOptions::DEFAULT_HTML
assert options.nonet?
assert options.recover?
options.nononet.norecover
assert ! options.nonet?
assert ! options.recover?
options.nonet.recover
assert options.nonet?
assert options.recover?
end

def test_chaining
options = Nokogiri::XML::ParseOptions.new.recover.noent
assert options.recover?
Expand Down

0 comments on commit 5998563

Please sign in to comment.