nokogiri-1.6.7.2/ 0000755 0000041 0000041 00000000000 12653651067 013551 5 ustar www-data www-data nokogiri-1.6.7.2/Rakefile 0000644 0000041 0000041 00000023422 12653651067 015221 0 ustar www-data www-data # -*- ruby -*-
require 'rubygems'
require 'shellwords'
gem 'hoe'
require 'hoe'
Hoe.plugin :debugging
Hoe.plugin :git
Hoe.plugin :gemspec
Hoe.plugin :bundler
Hoe.add_include_dirs '.'
GENERATED_PARSER = "lib/nokogiri/css/parser.rb"
GENERATED_TOKENIZER = "lib/nokogiri/css/tokenizer.rb"
def java?
/java/ === RUBY_PLATFORM
end
ENV['LANG'] = "en_US.UTF-8" # UBUNTU 10.04, Y U NO DEFAULT TO UTF-8?
CrossRuby = Struct.new(:version, :host) {
def ver
@ver ||= version[/\A[^-]+/]
end
def minor_ver
@minor_ver ||= ver[/\A\d\.\d(?=\.)/]
end
def api_ver_suffix
case minor_ver
when nil
raise "unsupported version: #{ver}"
when '1.9'
'191'
else
minor_ver.delete('.') << '0'
end
end
def platform
@platform ||=
case host
when /\Ax86_64-/
'x64-mingw32'
when /\Ai[3-6]86-/
'x86-mingw32'
else
raise "unsupported host: #{host}"
end
end
def tool(name)
(@binutils_prefix ||=
case platform
when 'x64-mingw32'
'x86_64-w64-mingw32-'
when 'x86-mingw32'
'i686-w64-mingw32-'
end) + name
end
def target
case platform
when 'x64-mingw32'
'pei-x86-64'
when 'x86-mingw32'
'pei-i386'
end
end
def libruby_dll
case platform
when 'x64-mingw32'
"x64-msvcrt-ruby#{api_ver_suffix}.dll"
when 'x86-mingw32'
"msvcrt-ruby#{api_ver_suffix}.dll"
end
end
def dlls
[
'kernel32.dll',
'msvcrt.dll',
'ws2_32.dll',
*(case
when ver >= '2.0.0'
'user32.dll'
end),
libruby_dll
]
end
}
CROSS_RUBIES = File.read('.cross_rubies').lines.flat_map { |line|
case line
when /\A([^#]+):([^#]+)/
CrossRuby.new($1, $2)
else
[]
end
}
ENV['RUBY_CC_VERSION'] ||= CROSS_RUBIES.map(&:ver).uniq.join(":")
HOE = Hoe.spec 'nokogiri' do
developer 'Aaron Patterson', 'aaronp@rubyforge.org'
developer 'Mike Dalessio', 'mike.dalessio@gmail.com'
developer 'Yoko Harada', 'yokolet@gmail.com'
developer 'Tim Elliott', 'tle@holymonkey.com'
developer 'Akinori MUSHA', 'knu@idaemons.org'
license "MIT"
self.readme_file = "README.md"
self.history_file = ['CHANGELOG', ENV['HLANG'], 'rdoc'].compact.join('.')
self.extra_rdoc_files = FileList['*.rdoc','ext/nokogiri/*.c']
self.clean_globs += [
'nokogiri.gemspec',
'lib/nokogiri/nokogiri.{bundle,jar,rb,so}',
'lib/nokogiri/[0-9].[0-9]'
]
self.clean_globs += Dir.glob("ports/*").reject { |d| d =~ %r{/archives$} }
unless java?
self.extra_deps += [
# Keep this version in sync with the one in extconf.rb !
["mini_portile2", "~> 2.0.0.rc2"],
]
end
self.extra_dev_deps += [
["hoe-bundler", ">= 1.1"],
["hoe-debugging", "~> 1.2.1"],
["hoe-gemspec", ">= 1.0"],
["hoe-git", ">= 1.4"],
["minitest", "~> 2.2.2"],
["rake", ">= 0.9"],
["rake-compiler", "~> 0.9.2"],
["rake-compiler-dock", "~> 0.4.2"],
["racc", ">= 1.4.6"],
["rexical", ">= 1.0.5"]
]
if java?
self.spec_extras = { :platform => 'java' }
else
self.spec_extras = {
:extensions => ["ext/nokogiri/extconf.rb"],
:required_ruby_version => '>= 1.9.2'
}
end
self.testlib = :minitest
end
# ----------------------------------------
def add_file_to_gem relative_path
target_path = File.join gem_build_path, relative_path
target_dir = File.dirname(target_path)
mkdir_p target_dir unless File.directory?(target_dir)
rm_f target_path
safe_ln relative_path, target_path
HOE.spec.files += [relative_path]
end
def gem_build_path
File.join 'pkg', HOE.spec.full_name
end
if java?
# TODO: clean this section up.
require "rake/javaextensiontask"
Rake::JavaExtensionTask.new("nokogiri", HOE.spec) do |ext|
jruby_home = RbConfig::CONFIG['prefix']
ext.ext_dir = 'ext/java'
ext.lib_dir = 'lib/nokogiri'
ext.source_version = '1.6'
ext.target_version = '1.6'
jars = ["#{jruby_home}/lib/jruby.jar"] + FileList['lib/*.jar']
ext.classpath = jars.map { |x| File.expand_path x }.join ':'
end
task gem_build_path => [:compile] do
add_file_to_gem 'lib/nokogiri/nokogiri.jar'
end
else
begin
require 'rake/extensioncompiler'
# Ensure mingw compiler is installed
Rake::ExtensionCompiler.mingw_host
mingw_available = true
rescue
mingw_available = false
end
require "rake/extensiontask"
HOE.spec.files.reject! { |f| f =~ %r{\.(java|jar)$} }
dependencies = YAML.load_file("dependencies.yml")
task gem_build_path do
%w[libxml2 libxslt].each do |lib|
version = dependencies[lib]
archive = File.join("ports", "archives", "#{lib}-#{version}.tar.gz")
add_file_to_gem archive
patchesdir = File.join("patches", lib)
patches = `#{['git', 'ls-files', patchesdir].shelljoin}`.split("\n").grep(/\.patch\z/)
patches.each { |patch|
add_file_to_gem patch
}
(untracked = Dir[File.join(patchesdir, '*.patch')] - patches).empty? or
at_exit {
untracked.each { |patch|
puts "** WARNING: untracked patch file not added to gem: #{patch}"
}
}
end
end
Rake::ExtensionTask.new("nokogiri", HOE.spec) do |ext|
ext.lib_dir = File.join(*['lib', 'nokogiri', ENV['FAT_DIR']].compact)
ext.config_options << ENV['EXTOPTS']
if mingw_available
ext.cross_compile = true
ext.cross_platform = CROSS_RUBIES.map(&:platform).uniq
ext.cross_config_options << "--enable-cross-build"
ext.cross_compiling do |spec|
libs = dependencies.map { |name, version| "#{name}-#{version}" }.join(', ')
spec.required_ruby_version = [
'>= 1.9.2',
"< #{CROSS_RUBIES.max_by(&:ver).minor_ver.succ}"
]
spec.post_install_message = <<-EOS
Nokogiri is built with the packaged libraries: #{libs}.
EOS
spec.files.reject! { |path| File.fnmatch?('ports/*', path) }
end
end
end
end
# ----------------------------------------
desc "Generate css/parser.rb and css/tokenizer.rex"
task 'generate' => [GENERATED_PARSER, GENERATED_TOKENIZER]
task 'gem:spec' => 'generate' if Rake::Task.task_defined?("gem:spec")
# This is a big hack to make sure that the racc and rexical
# dependencies in the Gemfile are constrainted to ruby platforms
# (i.e. MRI and Rubinius). There's no way to do that through hoe,
# and any solution will require changing hoe and hoe-bundler.
old_gemfile_task = Rake::Task['bundler:gemfile'] rescue nil
task 'bundler:gemfile' do
old_gemfile_task.invoke if old_gemfile_task
lines = File.open('Gemfile', 'r') { |f| f.readlines }.map do |line|
line =~ /racc|rexical/ ? "#{line.strip}, :platform => :ruby" : line
end
File.open('Gemfile', 'w') { |f| lines.each { |line| f.puts line } }
end
file GENERATED_PARSER => "lib/nokogiri/css/parser.y" do |t|
racc = RbConfig::CONFIG['target_os'] =~ /mswin32/ ? '' : `which racc`.strip
racc = "#{::RbConfig::CONFIG['bindir']}/racc" if racc.empty?
racc = %x{command -v racc}.strip if racc.empty?
sh "#{racc} -l -o #{t.name} #{t.prerequisites.first}"
end
file GENERATED_TOKENIZER => "lib/nokogiri/css/tokenizer.rex" do |t|
sh "rex --independent -o #{t.name} #{t.prerequisites.first}"
end
[:compile, :check_manifest].each do |task_name|
Rake::Task[task_name].prerequisites << GENERATED_PARSER
Rake::Task[task_name].prerequisites << GENERATED_TOKENIZER
end
# ----------------------------------------
desc "set environment variables to build and/or test with debug options"
task :debug do
ENV['NOKOGIRI_DEBUG'] = "true"
ENV['CFLAGS'] ||= ""
ENV['CFLAGS'] += " -DDEBUG"
end
require 'tasks/test'
task :java_debug do
ENV['JAVA_OPTS'] = '-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y' if java? && ENV['JAVA_DEBUG']
end
if java?
task :test_19 => :test
task :test_20 do
ENV['JRUBY_OPTS'] = "--2.0"
Rake::Task["test"].invoke
end
end
Rake::Task[:test].prerequisites << :compile
Rake::Task[:test].prerequisites << :java_debug
Rake::Task[:test].prerequisites << :check_extra_deps unless java?
if Hoe.plugins.include?(:debugging)
['valgrind', 'valgrind:mem', 'valgrind:mem0'].each do |task_name|
Rake::Task["test:#{task_name}"].prerequisites << :compile
end
end
# ----------------------------------------
def verify_dll(dll, cross_ruby)
dll_imports = cross_ruby.dlls
dump = `#{['env', 'LANG=C', cross_ruby.tool('objdump'), '-p', dll].shelljoin}`
raise "unexpected file format for generated dll #{dll}" unless /file format #{Regexp.quote(cross_ruby.target)}\s/ === dump
raise "export function Init_nokogiri not in dll #{dll}" unless /Table.*\sInit_nokogiri\s/mi === dump
# Verify that the expected DLL dependencies match the actual dependencies
# and that no further dependencies exist.
dll_imports_is = dump.scan(/DLL Name: (.*)$/).map(&:first).map(&:downcase).uniq
if dll_imports_is.sort != dll_imports.sort
raise "unexpected dll imports #{dll_imports_is.inspect} in #{dll}"
end
puts "#{dll}: Looks good!"
end
task :cross do
rake_compiler_config_path = File.expand_path("~/.rake-compiler/config.yml")
unless File.exists? rake_compiler_config_path
raise "rake-compiler has not installed any cross rubies. Try using rake-compiler-dev-box for building binary windows gems.'"
end
CROSS_RUBIES.each do |cross_ruby|
task "tmp/#{cross_ruby.platform}/nokogiri/#{cross_ruby.ver}/nokogiri.so" do |t|
# To reduce the gem file size strip mingw32 dlls before packaging
sh [cross_ruby.tool('strip'), '-S', t.name].shelljoin
verify_dll t.name, cross_ruby
end
end
end
desc "build a windows gem without all the ceremony."
task "gem:windows" do
require "rake_compiler_dock"
RakeCompilerDock.sh "bundle && rake cross native gem MAKE='nice make -j`nproc`' RUBY_CC_VERSION=#{ENV['RUBY_CC_VERSION']}"
end
# vim: syntax=Ruby
nokogiri-1.6.7.2/.cross_rubies 0000644 0000041 0000041 00000000266 12653651067 016260 0 ustar www-data www-data 1.9.3-p551:i586-mingw32msvc
2.0.0-p645:i686-w64-mingw32
2.0.0-p645:x86_64-w64-mingw32
2.1.6:i686-w64-mingw32
2.1.6:x86_64-w64-mingw32
2.2.2:i686-w64-mingw32
2.2.2:x86_64-w64-mingw32
nokogiri-1.6.7.2/.gemtest 0000644 0000041 0000041 00000000000 12653651067 015210 0 ustar www-data www-data nokogiri-1.6.7.2/bin/ 0000755 0000041 0000041 00000000000 12653651067 014321 5 ustar www-data www-data nokogiri-1.6.7.2/bin/nokogiri 0000755 0000041 0000041 00000005167 12653651067 016101 0 ustar www-data www-data #!/usr/bin/env ruby
require 'optparse'
require 'open-uri'
require 'uri'
require 'rubygems'
require 'nokogiri'
autoload :IRB, 'irb'
parse_class = Nokogiri
encoding = nil
# This module provides some tunables with the nokogiri CLI for use in
# your ~/.nokogirirc.
module Nokogiri::CLI
class << self
# Specify the console engine, defaulted to IRB.
#
# call-seq:
# require 'pry'
# Nokogiri::CLI.console = Pry
attr_writer :console
def console
case @console
when Symbol
Kernel.const_get(@console)
else
@console
end
end
attr_accessor :rcfile
end
self.rcfile = File.expand_path('~/.nokogirirc')
self.console = :IRB
end
opts = OptionParser.new do |opts|
opts.banner = "Nokogiri: an HTML, XML, SAX, and Reader parser"
opts.define_head "Usage: nokogiri [options]"
opts.separator ""
opts.separator "Examples:"
opts.separator " nokogiri http://www.ruby-lang.org/"
opts.separator " nokogiri ./public/index.html"
opts.separator " curl -s http://nokogiri.org | nokogiri -e'p $_.css(\"h1\").length'"
opts.separator ""
opts.separator "Options:"
opts.on("--type type", "Parse as type: xml or html (default: auto)", [:xml, :html]) do |v|
parse_class = {:xml => Nokogiri::XML, :html => Nokogiri::HTML}[v]
end
opts.on("-C file", "Specifies initialization file to load (default #{Nokogiri::CLI.rcfile})") do |v|
Nokogiri::CLI.rcfile = v
end
opts.on("-E", "--encoding encoding", "Read as encoding (default: #{encoding || 'none'})") do |v|
encoding = v
end
opts.on("-e command", "Specifies script from command-line.") do |v|
@script = v
end
opts.on("--rng ", "Validate using this rng file.") do |v|
@rng = open(v) {|f| Nokogiri::XML::RelaxNG(f)}
end
opts.on_tail("-?", "--help", "Show this message") do
puts opts
exit
end
opts.on_tail("-v", "--version", "Show version") do
puts Nokogiri::VersionInfo.instance.to_markdown
exit
end
end
opts.parse!
url = ARGV.shift
if url.to_s.strip.empty? && $stdin.tty?
puts opts
exit 1
end
if File.file?(Nokogiri::CLI.rcfile)
load Nokogiri::CLI.rcfile
end
if url || $stdin.tty?
case uri = (URI(url) rescue url)
when URI::HTTP
@doc = parse_class.parse(uri.read, url, encoding)
else
@doc = parse_class.parse(open(url).read, nil, encoding)
end
else
@doc = parse_class.parse($stdin, nil, encoding)
end
$_ = @doc
if @rng
@rng.validate(@doc).each do |error|
puts error.message
end
else
if @script
eval @script, binding, ''
else
puts "Your document is stored in @doc..."
Nokogiri::CLI.console.start
end
end
nokogiri-1.6.7.2/Manifest.txt 0000644 0000041 0000041 00000027701 12653651067 016067 0 ustar www-data www-data .autotest
.cross_rubies
.editorconfig
.gemtest
.travis.yml
CHANGELOG.ja.rdoc
CHANGELOG.rdoc
C_CODING_STYLE.rdoc
Gemfile
LICENSE.txt
Manifest.txt
README.md
ROADMAP.md
Rakefile
STANDARD_RESPONSES.md
Y_U_NO_GEMSPEC.md
appveyor.yml
bin/nokogiri
build_all
dependencies.yml
ext/java/nokogiri/EncodingHandler.java
ext/java/nokogiri/HtmlDocument.java
ext/java/nokogiri/HtmlElementDescription.java
ext/java/nokogiri/HtmlEntityLookup.java
ext/java/nokogiri/HtmlSaxParserContext.java
ext/java/nokogiri/HtmlSaxPushParser.java
ext/java/nokogiri/NokogiriService.java
ext/java/nokogiri/XmlAttr.java
ext/java/nokogiri/XmlAttributeDecl.java
ext/java/nokogiri/XmlCdata.java
ext/java/nokogiri/XmlComment.java
ext/java/nokogiri/XmlDocument.java
ext/java/nokogiri/XmlDocumentFragment.java
ext/java/nokogiri/XmlDtd.java
ext/java/nokogiri/XmlElement.java
ext/java/nokogiri/XmlElementContent.java
ext/java/nokogiri/XmlElementDecl.java
ext/java/nokogiri/XmlEntityDecl.java
ext/java/nokogiri/XmlEntityReference.java
ext/java/nokogiri/XmlNamespace.java
ext/java/nokogiri/XmlNode.java
ext/java/nokogiri/XmlNodeSet.java
ext/java/nokogiri/XmlProcessingInstruction.java
ext/java/nokogiri/XmlReader.java
ext/java/nokogiri/XmlRelaxng.java
ext/java/nokogiri/XmlSaxParserContext.java
ext/java/nokogiri/XmlSaxPushParser.java
ext/java/nokogiri/XmlSchema.java
ext/java/nokogiri/XmlSyntaxError.java
ext/java/nokogiri/XmlText.java
ext/java/nokogiri/XmlXpathContext.java
ext/java/nokogiri/XsltStylesheet.java
ext/java/nokogiri/internals/ClosedStreamException.java
ext/java/nokogiri/internals/HtmlDomParserContext.java
ext/java/nokogiri/internals/IgnoreSchemaErrorsErrorHandler.java
ext/java/nokogiri/internals/NokogiriBlockingQueueInputStream.java
ext/java/nokogiri/internals/NokogiriDocumentCache.java
ext/java/nokogiri/internals/NokogiriDomParser.java
ext/java/nokogiri/internals/NokogiriEncodingReaderWrapper.java
ext/java/nokogiri/internals/NokogiriEntityResolver.java
ext/java/nokogiri/internals/NokogiriErrorHandler.java
ext/java/nokogiri/internals/NokogiriHandler.java
ext/java/nokogiri/internals/NokogiriHelpers.java
ext/java/nokogiri/internals/NokogiriNamespaceCache.java
ext/java/nokogiri/internals/NokogiriNamespaceContext.java
ext/java/nokogiri/internals/NokogiriNonStrictErrorHandler.java
ext/java/nokogiri/internals/NokogiriNonStrictErrorHandler4NekoHtml.java
ext/java/nokogiri/internals/NokogiriStrictErrorHandler.java
ext/java/nokogiri/internals/NokogiriXPathFunction.java
ext/java/nokogiri/internals/NokogiriXPathFunctionResolver.java
ext/java/nokogiri/internals/NokogiriXPathVariableResolver.java
ext/java/nokogiri/internals/NokogiriXsltErrorListener.java
ext/java/nokogiri/internals/ParserContext.java
ext/java/nokogiri/internals/ReaderNode.java
ext/java/nokogiri/internals/SaveContextVisitor.java
ext/java/nokogiri/internals/SchemaErrorHandler.java
ext/java/nokogiri/internals/UncloseableInputStream.java
ext/java/nokogiri/internals/XmlDeclHandler.java
ext/java/nokogiri/internals/XmlDomParserContext.java
ext/java/nokogiri/internals/XmlSaxParser.java
ext/java/nokogiri/internals/XsltExtensionFunction.java
ext/java/nokogiri/internals/c14n/AttrCompare.java
ext/java/nokogiri/internals/c14n/C14nHelper.java
ext/java/nokogiri/internals/c14n/CanonicalFilter.java
ext/java/nokogiri/internals/c14n/CanonicalizationException.java
ext/java/nokogiri/internals/c14n/Canonicalizer.java
ext/java/nokogiri/internals/c14n/Canonicalizer11.java
ext/java/nokogiri/internals/c14n/Canonicalizer11_OmitComments.java
ext/java/nokogiri/internals/c14n/Canonicalizer11_WithComments.java
ext/java/nokogiri/internals/c14n/Canonicalizer20010315.java
ext/java/nokogiri/internals/c14n/Canonicalizer20010315Excl.java
ext/java/nokogiri/internals/c14n/Canonicalizer20010315ExclOmitComments.java
ext/java/nokogiri/internals/c14n/Canonicalizer20010315ExclWithComments.java
ext/java/nokogiri/internals/c14n/Canonicalizer20010315OmitComments.java
ext/java/nokogiri/internals/c14n/Canonicalizer20010315WithComments.java
ext/java/nokogiri/internals/c14n/CanonicalizerBase.java
ext/java/nokogiri/internals/c14n/CanonicalizerPhysical.java
ext/java/nokogiri/internals/c14n/CanonicalizerSpi.java
ext/java/nokogiri/internals/c14n/Constants.java
ext/java/nokogiri/internals/c14n/ElementProxy.java
ext/java/nokogiri/internals/c14n/HelperNodeList.java
ext/java/nokogiri/internals/c14n/IgnoreAllErrorHandler.java
ext/java/nokogiri/internals/c14n/InclusiveNamespaces.java
ext/java/nokogiri/internals/c14n/InvalidCanonicalizerException.java
ext/java/nokogiri/internals/c14n/NameSpaceSymbTable.java
ext/java/nokogiri/internals/c14n/NodeFilter.java
ext/java/nokogiri/internals/c14n/UtfHelpper.java
ext/java/nokogiri/internals/c14n/XMLUtils.java
ext/nokogiri/depend
ext/nokogiri/extconf.rb
ext/nokogiri/html_document.c
ext/nokogiri/html_document.h
ext/nokogiri/html_element_description.c
ext/nokogiri/html_element_description.h
ext/nokogiri/html_entity_lookup.c
ext/nokogiri/html_entity_lookup.h
ext/nokogiri/html_sax_parser_context.c
ext/nokogiri/html_sax_parser_context.h
ext/nokogiri/html_sax_push_parser.c
ext/nokogiri/html_sax_push_parser.h
ext/nokogiri/nokogiri.c
ext/nokogiri/nokogiri.h
ext/nokogiri/xml_attr.c
ext/nokogiri/xml_attr.h
ext/nokogiri/xml_attribute_decl.c
ext/nokogiri/xml_attribute_decl.h
ext/nokogiri/xml_cdata.c
ext/nokogiri/xml_cdata.h
ext/nokogiri/xml_comment.c
ext/nokogiri/xml_comment.h
ext/nokogiri/xml_document.c
ext/nokogiri/xml_document.h
ext/nokogiri/xml_document_fragment.c
ext/nokogiri/xml_document_fragment.h
ext/nokogiri/xml_dtd.c
ext/nokogiri/xml_dtd.h
ext/nokogiri/xml_element_content.c
ext/nokogiri/xml_element_content.h
ext/nokogiri/xml_element_decl.c
ext/nokogiri/xml_element_decl.h
ext/nokogiri/xml_encoding_handler.c
ext/nokogiri/xml_encoding_handler.h
ext/nokogiri/xml_entity_decl.c
ext/nokogiri/xml_entity_decl.h
ext/nokogiri/xml_entity_reference.c
ext/nokogiri/xml_entity_reference.h
ext/nokogiri/xml_io.c
ext/nokogiri/xml_io.h
ext/nokogiri/xml_libxml2_hacks.c
ext/nokogiri/xml_libxml2_hacks.h
ext/nokogiri/xml_namespace.c
ext/nokogiri/xml_namespace.h
ext/nokogiri/xml_node.c
ext/nokogiri/xml_node.h
ext/nokogiri/xml_node_set.c
ext/nokogiri/xml_node_set.h
ext/nokogiri/xml_processing_instruction.c
ext/nokogiri/xml_processing_instruction.h
ext/nokogiri/xml_reader.c
ext/nokogiri/xml_reader.h
ext/nokogiri/xml_relax_ng.c
ext/nokogiri/xml_relax_ng.h
ext/nokogiri/xml_sax_parser.c
ext/nokogiri/xml_sax_parser.h
ext/nokogiri/xml_sax_parser_context.c
ext/nokogiri/xml_sax_parser_context.h
ext/nokogiri/xml_sax_push_parser.c
ext/nokogiri/xml_sax_push_parser.h
ext/nokogiri/xml_schema.c
ext/nokogiri/xml_schema.h
ext/nokogiri/xml_syntax_error.c
ext/nokogiri/xml_syntax_error.h
ext/nokogiri/xml_text.c
ext/nokogiri/xml_text.h
ext/nokogiri/xml_xpath_context.c
ext/nokogiri/xml_xpath_context.h
ext/nokogiri/xslt_stylesheet.c
ext/nokogiri/xslt_stylesheet.h
lib/isorelax.jar
lib/jing.jar
lib/nekodtd.jar
lib/nekohtml.jar
lib/nokogiri.rb
lib/nokogiri/css.rb
lib/nokogiri/css/node.rb
lib/nokogiri/css/parser.rb
lib/nokogiri/css/parser.y
lib/nokogiri/css/parser_extras.rb
lib/nokogiri/css/syntax_error.rb
lib/nokogiri/css/tokenizer.rb
lib/nokogiri/css/tokenizer.rex
lib/nokogiri/css/xpath_visitor.rb
lib/nokogiri/decorators/slop.rb
lib/nokogiri/html.rb
lib/nokogiri/html/builder.rb
lib/nokogiri/html/document.rb
lib/nokogiri/html/document_fragment.rb
lib/nokogiri/html/element_description.rb
lib/nokogiri/html/element_description_defaults.rb
lib/nokogiri/html/entity_lookup.rb
lib/nokogiri/html/sax/parser.rb
lib/nokogiri/html/sax/parser_context.rb
lib/nokogiri/html/sax/push_parser.rb
lib/nokogiri/syntax_error.rb
lib/nokogiri/version.rb
lib/nokogiri/xml.rb
lib/nokogiri/xml/attr.rb
lib/nokogiri/xml/attribute_decl.rb
lib/nokogiri/xml/builder.rb
lib/nokogiri/xml/cdata.rb
lib/nokogiri/xml/character_data.rb
lib/nokogiri/xml/document.rb
lib/nokogiri/xml/document_fragment.rb
lib/nokogiri/xml/dtd.rb
lib/nokogiri/xml/element_content.rb
lib/nokogiri/xml/element_decl.rb
lib/nokogiri/xml/entity_decl.rb
lib/nokogiri/xml/namespace.rb
lib/nokogiri/xml/node.rb
lib/nokogiri/xml/node/save_options.rb
lib/nokogiri/xml/node_set.rb
lib/nokogiri/xml/notation.rb
lib/nokogiri/xml/parse_options.rb
lib/nokogiri/xml/pp.rb
lib/nokogiri/xml/pp/character_data.rb
lib/nokogiri/xml/pp/node.rb
lib/nokogiri/xml/processing_instruction.rb
lib/nokogiri/xml/reader.rb
lib/nokogiri/xml/relax_ng.rb
lib/nokogiri/xml/sax.rb
lib/nokogiri/xml/sax/document.rb
lib/nokogiri/xml/sax/parser.rb
lib/nokogiri/xml/sax/parser_context.rb
lib/nokogiri/xml/sax/push_parser.rb
lib/nokogiri/xml/schema.rb
lib/nokogiri/xml/searchable.rb
lib/nokogiri/xml/syntax_error.rb
lib/nokogiri/xml/text.rb
lib/nokogiri/xml/xpath.rb
lib/nokogiri/xml/xpath/syntax_error.rb
lib/nokogiri/xml/xpath_context.rb
lib/nokogiri/xslt.rb
lib/nokogiri/xslt/stylesheet.rb
lib/xercesImpl.jar
lib/xsd/xmlparser/nokogiri.rb
patches/sort-patches-by-date
suppressions/README.txt
suppressions/nokogiri_ree-1.8.7.358.supp
suppressions/nokogiri_ruby-1.8.7.370.supp
suppressions/nokogiri_ruby-1.9.2.320.supp
suppressions/nokogiri_ruby-1.9.3.327.supp
tasks/test.rb
test/css/test_nthiness.rb
test/css/test_parser.rb
test/css/test_tokenizer.rb
test/css/test_xpath_visitor.rb
test/decorators/test_slop.rb
test/files/2ch.html
test/files/address_book.rlx
test/files/address_book.xml
test/files/atom.xml
test/files/bar/bar.xsd
test/files/bogus.xml
test/files/dont_hurt_em_why.xml
test/files/encoding.html
test/files/encoding.xhtml
test/files/exslt.xml
test/files/exslt.xslt
test/files/foo/foo.xsd
test/files/metacharset.html
test/files/noencoding.html
test/files/po.xml
test/files/po.xsd
test/files/saml/saml20assertion_schema.xsd
test/files/saml/saml20protocol_schema.xsd
test/files/saml/xenc_schema.xsd
test/files/saml/xmldsig_schema.xsd
test/files/shift_jis.html
test/files/shift_jis.xml
test/files/shift_jis_no_charset.html
test/files/slow-xpath.xml
test/files/snuggles.xml
test/files/staff.dtd
test/files/staff.xml
test/files/staff.xslt
test/files/test_document_url/bar.xml
test/files/test_document_url/document.dtd
test/files/test_document_url/document.xml
test/files/tlm.html
test/files/to_be_xincluded.xml
test/files/valid_bar.xml
test/files/xinclude.xml
test/helper.rb
test/html/sax/test_parser.rb
test/html/sax/test_parser_context.rb
test/html/sax/test_push_parser.rb
test/html/test_builder.rb
test/html/test_document.rb
test/html/test_document_encoding.rb
test/html/test_document_fragment.rb
test/html/test_element_description.rb
test/html/test_named_characters.rb
test/html/test_node.rb
test/html/test_node_encoding.rb
test/namespaces/test_additional_namespaces_in_builder_doc.rb
test/namespaces/test_namespaces_aliased_default.rb
test/namespaces/test_namespaces_in_builder_doc.rb
test/namespaces/test_namespaces_in_cloned_doc.rb
test/namespaces/test_namespaces_in_created_doc.rb
test/namespaces/test_namespaces_in_parsed_doc.rb
test/namespaces/test_namespaces_preservation.rb
test/test_convert_xpath.rb
test/test_css_cache.rb
test/test_encoding_handler.rb
test/test_memory_leak.rb
test/test_nokogiri.rb
test/test_reader.rb
test/test_soap4r_sax.rb
test/test_xslt_transforms.rb
test/xml/node/test_save_options.rb
test/xml/node/test_subclass.rb
test/xml/sax/test_parser.rb
test/xml/sax/test_parser_context.rb
test/xml/sax/test_push_parser.rb
test/xml/test_attr.rb
test/xml/test_attribute_decl.rb
test/xml/test_builder.rb
test/xml/test_c14n.rb
test/xml/test_cdata.rb
test/xml/test_comment.rb
test/xml/test_document.rb
test/xml/test_document_encoding.rb
test/xml/test_document_fragment.rb
test/xml/test_dtd.rb
test/xml/test_dtd_encoding.rb
test/xml/test_element_content.rb
test/xml/test_element_decl.rb
test/xml/test_entity_decl.rb
test/xml/test_entity_reference.rb
test/xml/test_namespace.rb
test/xml/test_node.rb
test/xml/test_node_attributes.rb
test/xml/test_node_encoding.rb
test/xml/test_node_inheritance.rb
test/xml/test_node_reparenting.rb
test/xml/test_node_set.rb
test/xml/test_parse_options.rb
test/xml/test_processing_instruction.rb
test/xml/test_reader_encoding.rb
test/xml/test_relax_ng.rb
test/xml/test_schema.rb
test/xml/test_syntax_error.rb
test/xml/test_text.rb
test/xml/test_unparented_node.rb
test/xml/test_xinclude.rb
test/xml/test_xpath.rb
test/xslt/test_custom_functions.rb
test/xslt/test_exception_handling.rb
test_all
nokogiri-1.6.7.2/Gemfile 0000644 0000041 0000041 00000001642 12653651067 015047 0 ustar www-data www-data # -*- ruby -*-
# DO NOT EDIT THIS FILE. Instead, edit Rakefile, and run `rake bundler:gemfile`.
source "https://rubygems.org/"
gem "mini_portile2", "~>2.0.0.rc2"
gem "rdoc", "~>4.0", :group => [:development, :test]
gem "hoe-bundler", ">=1.1", :group => [:development, :test]
gem "hoe-debugging", "~>1.2.1", :group => [:development, :test]
gem "hoe-gemspec", ">=1.0", :group => [:development, :test]
gem "hoe-git", ">=1.4", :group => [:development, :test]
gem "minitest", "~>2.2.2", :group => [:development, :test]
gem "rake", ">=0.9", :group => [:development, :test]
gem "rake-compiler", "~>0.9.2", :group => [:development, :test]
gem "rake-compiler-dock", "~>0.4.2", :group => [:development, :test]
gem "racc", ">=1.4.6", :group => [:development, :test], :platform => :ruby
gem "rexical", ">=1.0.5", :group => [:development, :test], :platform => :ruby
gem "hoe", "~>3.14", :group => [:development, :test]
# vim: syntax=ruby
nokogiri-1.6.7.2/.autotest 0000644 0000041 0000041 00000000700 12653651067 015417 0 ustar www-data www-data # -*- ruby -*-
begin
require 'autotest/fsevent'
rescue LoadError
end
Autotest.add_hook :initialize do |at|
at.add_exception /bundle$/
at.add_exception /\.git/
end
Autotest.add_hook :run_command do |at|
at.unit_diff = 'cat'
if ENV['ONENINE']
system "rake1.9 compile"
else
system "rake compile"
end
end
Autotest.add_hook :ran_command do |at|
File.open('/tmp/autotest.txt', 'wb') { |f|
f.write(at.results.join)
}
end
nokogiri-1.6.7.2/.editorconfig 0000644 0000041 0000041 00000000315 12653651067 016225 0 ustar www-data www-data root = true
[**]
end_of_line = lf
insert_final_newline = true
[**.rb]
indent_style = space
indent_size = 2
[**.[ch]]
indent_style = space
indent_size = 2
[**.java]
indent_style = space
indent_size = 4
nokogiri-1.6.7.2/patches/ 0000755 0000041 0000041 00000000000 12653651067 015200 5 ustar www-data www-data nokogiri-1.6.7.2/patches/sort-patches-by-date 0000755 0000041 0000041 00000001204 12653651067 021062 0 ustar www-data www-data #! /usr/bin/env ruby
require "date"
dir = ARGV[0] || raise("ERROR: arg1 must be dir")
Dir.chdir dir
files_and_times = {}
Dir["*.patch"].sort.each do |filename|
dateline = `cat #{filename} | grep "Date:"`
datestr = dateline.split("Date:").last.strip
time = DateTime.parse datestr
files_and_times[filename] = time
end
count = 0
files_and_times.sort_by {|k,v| v}.each do |filename, time|
count += 1
_, patch_name = filename.split("-", 2)
new_filename = sprintf("%4.4d-%s", count, patch_name)
printf "mv -f %s %s # %s\n", filename, new_filename, time
end
STDERR.print "\n**\n** REMEMBER TO UPDATE THE Manifest.txt FILE\n**\n"
nokogiri-1.6.7.2/patches/libxml2/ 0000755 0000041 0000041 00000000000 12653651067 016551 5 ustar www-data www-data nokogiri-1.6.7.2/patches/libxml2/0018-CVE-2015-8242-Buffer-overead-with-HTML-parser-in-pus.patch 0000644 0000041 0000041 00000002522 12653651067 030630 0 ustar www-data www-data From 37bc5395ae2489db988b37b4dba070c584b516ca Mon Sep 17 00:00:00 2001
From: Hugh Davenport
Date: Fri, 20 Nov 2015 17:16:06 +0800
Subject: [PATCH 18/18] CVE-2015-8242 Buffer overead with HTML parser in push
mode
For https://bugzilla.gnome.org/show_bug.cgi?id=756372
Error in the code pointing to the codepoint in the stack for the
current char value instead of the pointer in the input that the SAX
callback expects
Reported and fixed by Hugh Davenport
---
HTMLparser.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/HTMLparser.c b/HTMLparser.c
index bdf7807..b729197 100644
--- a/HTMLparser.c
+++ b/HTMLparser.c
@@ -5735,17 +5735,17 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
if (ctxt->keepBlanks) {
if (ctxt->sax->characters != NULL)
ctxt->sax->characters(
- ctxt->userData, &cur, 1);
+ ctxt->userData, &in->cur[0], 1);
} else {
if (ctxt->sax->ignorableWhitespace != NULL)
ctxt->sax->ignorableWhitespace(
- ctxt->userData, &cur, 1);
+ ctxt->userData, &in->cur[0], 1);
}
} else {
htmlCheckParagraph(ctxt);
if (ctxt->sax->characters != NULL)
ctxt->sax->characters(
- ctxt->userData, &cur, 1);
+ ctxt->userData, &in->cur[0], 1);
}
}
ctxt->token = 0;
--
2.5.0
nokogiri-1.6.7.2/patches/libxml2/0001-Revert-Missing-initialization-for-the-catalog-module.patch 0000644 0000041 0000041 00000001402 12653651067 032305 0 ustar www-data www-data From f65128f38289d77ff322d63aef2858cc0a819c34 Mon Sep 17 00:00:00 2001
From: Daniel Veillard
Date: Fri, 17 Oct 2014 17:13:41 +0800
Subject: [PATCH] Revert "Missing initialization for the catalog module"
This reverts commit 054c716ea1bf001544127a4ab4f4346d1b9947e7.
As this break xmlcatalog command
https://bugzilla.redhat.com/show_bug.cgi?id=1153753
---
parser.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/parser.c b/parser.c
index 1d93967..67c9dfd 100644
--- a/parser.c
+++ b/parser.c
@@ -14830,9 +14830,6 @@ xmlInitParser(void) {
#ifdef LIBXML_XPATH_ENABLED
xmlXPathInit();
#endif
-#ifdef LIBXML_CATALOG_ENABLED
- xmlInitializeCatalog();
-#endif
xmlParserInitialized = 1;
#ifdef LIBXML_THREAD_ENABLED
}
--
2.1.2
././@LongLink 0000000 0000000 0000000 00000000146 00000000000 011566 L ustar root root nokogiri-1.6.7.2/patches/libxml2/0010-Fix-parsering-short-unclosed-comment-uninitialized-access.patch nokogiri-1.6.7.2/patches/libxml2/0010-Fix-parsering-short-unclosed-comment-uninitialized-access.patc0000644 0000041 0000041 00000003334 12653651067 033235 0 ustar www-data www-data From e724879d964d774df9b7969fc846605aa1bac54c Mon Sep 17 00:00:00 2001
From: Daniel Veillard
Date: Fri, 30 Oct 2015 21:14:55 +0800
Subject: Fix parsing short unclosed comment uninitialized access
For https://bugzilla.gnome.org/show_bug.cgi?id=746048
The HTML parser was too optimistic when processing comments and
didn't check for the end of the stream on the first 2 characters
---
HTMLparser.c | 21 ++++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)
diff --git a/HTMLparser.c b/HTMLparser.c
index 19c10c3..bdf7807 100644
--- a/HTMLparser.c
+++ b/HTMLparser.c
@@ -3264,12 +3264,17 @@ htmlParseComment(htmlParserCtxtPtr ctxt) {
ctxt->instate = state;
return;
}
+ len = 0;
+ buf[len] = 0;
q = CUR_CHAR(ql);
+ if (!IS_CHAR(q))
+ goto unfinished;
NEXTL(ql);
r = CUR_CHAR(rl);
+ if (!IS_CHAR(r))
+ goto unfinished;
NEXTL(rl);
cur = CUR_CHAR(l);
- len = 0;
while (IS_CHAR(cur) &&
((cur != '>') ||
(r != '-') || (q != '-'))) {
@@ -3300,18 +3305,20 @@ htmlParseComment(htmlParserCtxtPtr ctxt) {
}
}
buf[len] = 0;
- if (!IS_CHAR(cur)) {
- htmlParseErr(ctxt, XML_ERR_COMMENT_NOT_FINISHED,
- "Comment not terminated \n
Paragraph 1
eoxml
assert ! @parser.document.end_document_called
@parser.finish
assert @parser.document.end_document_called
end
def test_start_element
@parser.<<(<<-eoxml)
eoxml
assert_equal [["html", []], ["head", []], ["body", []], ["p", [["id", "asdfasdf"]]]],
@parser.document.start_elements
@parser.<<(<<-eoxml)
Paragraph 1
eoxml
assert_equal [' This is a comment '], @parser.document.comments
@parser.finish
end
def test_chevron_partial_html
@parser.<<(<<-eoxml)
eoxml
@parser.<<(<<-eoxml)
Paragraph 1
eoxml
assert_equal [' This is a comment '], @parser.document.comments
@parser.finish
end
def test_chevron
@parser.<<(<<-eoxml)
Paragraph 1
eoxml
@parser.finish
assert_equal [' This is a comment '], @parser.document.comments
end
def test_default_options
assert_equal 0, @parser.options
end
def test_broken_encoding
skip("ultra hard to fix for pure Java version") if Nokogiri.jruby?
@parser.options |= XML::ParseOptions::RECOVER
# This is ISO_8859-1:
@parser.<< "Gau\337"
@parser.finish
assert(@parser.document.errors.size >= 1)
assert_equal "Gau\337", @parser.document.data.join
assert_equal [["r"], ["body"], ["html"]], @parser.document.end_elements
end
end
end
end
end
nokogiri-1.6.7.2/test/html/sax/test_parser_context.rb 0000644 0000041 0000041 00000002021 12653651067 022706 0 ustar www-data www-data # -*- coding: utf-8 -*-
require "helper"
module Nokogiri
module HTML
module SAX
class TestParserContext < Nokogiri::SAX::TestCase
def test_from_io
ctx = ParserContext.new StringIO.new('fo'), 'UTF-8'
assert ctx
end
def test_from_string
ctx = ParserContext.new 'blah blah'
assert ctx
end
def test_parse_with
ctx = ParserContext.new 'blah'
assert_raises ArgumentError do
ctx.parse_with nil
end
end
def test_parse_with_sax_parser
# assert_nothing_raised do
xml = ""
ctx = ParserContext.new xml
parser = Parser.new Doc.new
ctx.parse_with parser
# end
end
def test_from_file
# assert_nothing_raised do
ctx = ParserContext.file HTML_FILE, 'UTF-8'
parser = Parser.new Doc.new
ctx.parse_with parser
# end
end
end
end
end
end
nokogiri-1.6.7.2/test/html/sax/test_parser.rb 0000644 0000041 0000041 00000010021 12653651067 021141 0 ustar www-data www-data # -*- coding: utf-8 -*-
require "helper"
module Nokogiri
module HTML
module SAX
class TestParser < Nokogiri::SAX::TestCase
def setup
super
@parser = HTML::SAX::Parser.new(Doc.new)
end
def test_parse_empty_document
# This caused a segfault in libxml 2.6.x
assert_nil @parser.parse ''
end
def test_parse_empty_file
# Make sure empty files don't break stuff
empty_file_name = File.join(ASSETS_DIR, 'bogus.xml')
# assert_nothing_raised do
@parser.parse_file empty_file_name
# end
end
def test_parse_file
@parser.parse_file(HTML_FILE)
# Take a look at the comment in test_parse_document to know
# a possible reason to this difference.
if Nokogiri.uses_libxml?
assert_equal 1110, @parser.document.end_elements.length
else
assert_equal 1119, @parser.document.end_elements.length
end
end
def test_parse_file_nil_argument
assert_raises(ArgumentError) {
@parser.parse_file(nil)
}
end
def test_parse_file_non_existant
assert_raise Errno::ENOENT do
@parser.parse_file('there_is_no_reasonable_way_this_file_exists')
end
end
def test_parse_file_with_dir
assert_raise Errno::EISDIR do
@parser.parse_file(File.dirname(__FILE__))
end
end
def test_parse_memory_nil
assert_raise ArgumentError do
@parser.parse_memory(nil)
end
end
def test_parse_force_encoding
@parser.parse_memory(<<-HTML, 'UTF-8')
Информация
HTML
assert_equal("Информация",
@parser.document.data.join.strip)
end
def test_parse_document
@parser.parse_memory(<<-eoxml)
Paragraph 1
Paragraph 2
eoxml
# JRuby version is different because of the internal implementation
# JRuby version uses NekoHTML which inserts empty "head" elements.
#
# Currently following features are set:
# "http://cyberneko.org/html/properties/names/elems" => "lower"
# "http://cyberneko.org/html/properties/names/attrs" => "lower"
if Nokogiri.uses_libxml?
assert_equal([["html", []], ["body", []], ["p", []], ["p", []]],
@parser.document.start_elements)
else
assert_equal([["html", []], ["head", []], ["body", []], ["p", []], ["p", []]],
@parser.document.start_elements)
end
end
def test_parser_attributes
html = <<-eohtml
hello
eohtml
block_called = false
@parser.parse(html) { |ctx|
block_called = true
ctx.replace_entities = true
}
assert block_called
noshade_value = if Nokogiri.uses_libxml? && Nokogiri::VERSION_INFO['libxml']['loaded'] < '2.7.7'
['noshade', 'noshade']
else
['noshade', nil]
end
assert_equal [
['html', []],
['head', []],
['title', []],
['body', []],
['img', [
['src', 'face.jpg'],
['title', 'daddy & me']
]],
['hr', [
noshade_value,
['size', '2']
]]
], @parser.document.start_elements
end
def test_empty_processing_instruction
@parser.parse_memory("this will segfault")
end
end
end
end
end
nokogiri-1.6.7.2/test/html/test_builder.rb 0000644 0000041 0000041 00000011030 12653651067 020501 0 ustar www-data www-data require "helper"
module Nokogiri
module HTML
class TestBuilder < Nokogiri::TestCase
def test_top_level_function_builds
foo = nil
Nokogiri() { |xml| foo = xml }
assert_instance_of Nokogiri::HTML::Builder, foo
end
def test_builder_with_explicit_tags
html_doc = Nokogiri::HTML::Builder.new {
div.slide(:class => 'another_class') {
node = Nokogiri::XML::Node.new("id", doc)
node.content = "hello"
insert(node)
}
}.doc
assert_equal 1, html_doc.css('div.slide > id').length
assert_equal 'hello', html_doc.at('div.slide > id').content
end
def test_hash_as_attributes_for_attribute_method
html = Nokogiri::HTML::Builder.new { ||
div.slide(:class => 'another_class') {
span 'Slide 1'
}
}.to_html
assert_match 'class="slide another_class"', html
end
def test_hash_as_attributes
builder = Nokogiri::HTML::Builder.new do
div(:id => 'awesome') {
h1 "america"
}
end
assert_equal('america
',
builder.doc.root.to_html.gsub(/\n/, '').gsub(/>\s*, '><'))
end
def test_href_with_attributes
uri = 'http://tenderlovemaking.com/'
built = Nokogiri::XML::Builder.new {
div {
a('King Khan & The Shrines', :href => uri)
}
}
assert_equal 'http://tenderlovemaking.com/',
built.doc.at('a')[:href]
end
def test_tag_nesting
builder = Nokogiri::HTML::Builder.new do
body {
span.left ''
span.middle {
div.icon ''
}
span.right ''
}
end
assert node = builder.doc.css('span.right').first
assert_equal 'middle', node.previous_sibling['class']
end
def test_has_ampersand
builder = Nokogiri::HTML::Builder.new do
div.rad.thing! {
text ""
b "hello & world"
}
end
assert_equal(
'<awe&some>hello & world
',
builder.doc.root.to_html.gsub(/\n/, ''))
end
def test_multi_tags
builder = Nokogiri::HTML::Builder.new do
div.rad.thing! {
text ""
b "hello"
}
end
assert_equal(
'<awesome>hello
',
builder.doc.root.to_html.gsub(/\n/, ''))
end
def test_attributes_plus_block
builder = Nokogiri::HTML::Builder.new do
div.rad.thing! {
text ""
}
end
assert_equal('<awesome>
',
builder.doc.root.to_html.chomp)
end
def test_builder_adds_attributes
builder = Nokogiri::HTML::Builder.new do
div.rad.thing! "tender div"
end
assert_equal('tender div
',
builder.doc.root.to_html.chomp)
end
def test_bold_tag
builder = Nokogiri::HTML::Builder.new do
b "bold tag"
end
assert_equal('bold tag', builder.doc.root.to_html.chomp)
end
def test_html_then_body_tag
builder = Nokogiri::HTML::Builder.new do
html {
body {
b "bold tag"
}
}
end
assert_equal('bold tag',
builder.doc.root.to_html.chomp.gsub(/>\s*, '><'))
end
def test_instance_eval_with_delegation_to_block_context
class << self
def foo
"foo!"
end
end
builder = Nokogiri::HTML::Builder.new { text foo }
assert builder.to_html.include?("foo!")
end
def test_builder_with_param
doc = Nokogiri::HTML::Builder.new { |html|
html.body {
html.p "hello world"
}
}.doc
assert node = doc.xpath('//body/p').first
assert_equal 'hello world', node.content
end
def test_builder_with_id
text = "hello world"
doc = Nokogiri::HTML::Builder.new { |html|
html.body {
html.id_ text
}
}.doc
assert node = doc.xpath('//body/id').first
assert_equal text, node.content
end
end
end
end
nokogiri-1.6.7.2/test/html/test_node_encoding.rb 0000644 0000041 0000041 00000001307 12653651067 021654 0 ustar www-data www-data # -*- coding: utf-8 -*-
require "helper"
module Nokogiri
module HTML
if RUBY_VERSION =~ /^1\.9/
class TestNodeEncoding < Nokogiri::TestCase
def test_inner_html
doc = Nokogiri::HTML File.open(SHIFT_JIS_HTML, 'rb')
hello = "こんにちは"
contents = doc.at('h2').inner_html
assert_equal doc.encoding, contents.encoding.name
assert_match hello.encode('Shift_JIS'), contents
contents = doc.at('h2').inner_html(:encoding => 'UTF-8')
assert_match hello, contents
doc.encoding = 'UTF-8'
contents = doc.at('h2').inner_html
assert_match hello, contents
end
end
end
end
end
nokogiri-1.6.7.2/test/html/test_document.rb 0000644 0000041 0000041 00000044560 12653651067 020707 0 ustar www-data www-data require "helper"
module Nokogiri
module HTML
class TestDocument < Nokogiri::TestCase
def setup
super
@html = Nokogiri::HTML.parse(File.read(HTML_FILE))
end
def test_nil_css
# Behavior is undefined but shouldn't break
assert @html.css(nil)
assert @html.xpath(nil)
end
def test_does_not_fail_with_illformatted_html
doc = Nokogiri::HTML('"";'.force_encoding(Encoding::BINARY))
assert_not_nil doc
end
def test_exceptions_remove_newlines
errors = @html.errors
assert errors.length > 0, 'has errors'
errors.each do |error|
assert_equal(error.to_s.chomp, error.to_s)
end
end
def test_fragment
fragment = @html.fragment
assert_equal 0, fragment.children.length
end
def test_document_takes_config_block
options = nil
Nokogiri::HTML(File.read(HTML_FILE), HTML_FILE) do |cfg|
options = cfg
options.nonet.nowarning.dtdattr
end
assert options.nonet?
assert options.nowarning?
assert options.dtdattr?
end
def test_parse_takes_config_block
options = nil
Nokogiri::HTML.parse(File.read(HTML_FILE), HTML_FILE) do |cfg|
options = cfg
options.nonet.nowarning.dtdattr
end
assert options.nonet?
assert options.nowarning?
assert options.dtdattr?
end
def test_subclass
klass = Class.new(Nokogiri::HTML::Document)
doc = klass.new
assert_instance_of klass, doc
end
def test_subclass_initialize
klass = Class.new(Nokogiri::HTML::Document) do
attr_accessor :initialized_with
def initialize(*args)
@initialized_with = args
end
end
doc = klass.new("uri", "external_id", 1)
assert_equal ["uri", "external_id", 1], doc.initialized_with
end
def test_subclass_dup
klass = Class.new(Nokogiri::HTML::Document)
doc = klass.new.dup
assert_instance_of klass, doc
end
def test_subclass_parse
klass = Class.new(Nokogiri::HTML::Document)
doc = klass.parse(File.read(HTML_FILE))
assert_equal @html.to_s, doc.to_s
assert_instance_of klass, doc
end
def test_document_parse_method
html = Nokogiri::HTML::Document.parse(File.read(HTML_FILE))
assert_equal @html.to_s, html.to_s
end
def test_document_parse_method_with_url
require 'open-uri'
begin
html = open('https://www.yahoo.com').read
rescue Exception => e
skip("This test needs the internet. Skips if no internet available. (#{e})")
end
doc = Nokogiri::HTML html ,"http:/foobar.foobar/"
refute_empty doc.to_s, "Document should not be empty"
end
###
# Nokogiri::HTML returns an empty Document when given a blank string GH#11
def test_empty_string_returns_empty_doc
doc = Nokogiri::HTML('')
assert_instance_of Nokogiri::HTML::Document, doc
assert_nil doc.root
end
unless Nokogiri.uses_libxml? && %w[2 6] === LIBXML_VERSION.split('.')[0..1]
# FIXME: this is a hack around broken libxml versions
def test_to_xhtml_with_indent
doc = Nokogiri::HTML('foo')
doc = Nokogiri::HTML(doc.to_xhtml(:indent => 2))
assert_indent 2, doc
end
def test_write_to_xhtml_with_indent
io = StringIO.new
doc = Nokogiri::HTML('foo')
doc.write_xhtml_to io, :indent => 5
io.rewind
doc = Nokogiri::HTML(io.read)
assert_indent 5, doc
end
end
def test_swap_should_not_exist
assert_raises(NoMethodError) {
@html.swap
}
end
def test_namespace_should_not_exist
assert_raises(NoMethodError) {
@html.namespace
}
end
def test_meta_encoding
assert_equal 'UTF-8', @html.meta_encoding
end
def test_meta_encoding_is_strict_about_http_equiv
doc = Nokogiri::HTML(<<-eohtml)
foo
eohtml
assert_nil doc.meta_encoding
end
def test_meta_encoding_handles_malformed_content_charset
doc = Nokogiri::HTML(<
foo