Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Let catch() generate a random tag on Ruby 1.9.

  • Loading branch information...
commit 24649c26f13934b6bad70a00249f434d6a49270d 1 parent 1be1472
@knu knu authored
Showing with 8 additions and 4 deletions.
  1. +8 −4 lib/nokogiri/html/document.rb
View
12 lib/nokogiri/html/document.rb
@@ -135,8 +135,13 @@ def initialize(encoding)
class EncodingReader # :nodoc:
class SAXHandler < Nokogiri::XML::SAX::Document # :nodoc:
+ def initialize(jumptag)
+ @jumptag = jumptag
+ super()
+ end
+
def found(encoding)
- throw :found, encoding
+ throw @jumptag, encoding
end
def not_found(encoding)
@@ -169,9 +174,8 @@ def self.detect_encoding(chunk)
return m[4]
end
- parser = Nokogiri::HTML::SAX::Parser.new(SAXHandler.new)
- catch(:found) {
- parser.parse(chunk)
+ catch(*if RUBY_VERSION < '1.9' then :encoding_found end) { |tag|
+ Nokogiri::HTML::SAX::Parser.new(SAXHandler.new(tag)).parse(chunk)
nil
}
rescue
Please sign in to comment.
Something went wrong with that request. Please try again.