nokogiri 1.4.7-x86-mingw32 → 1.5.0-x86-mingw32

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.

Files changed (132) hide show
  1. data/CHANGELOG.ja.rdoc +59 -1
  2. data/CHANGELOG.rdoc +51 -2
  3. data/Manifest.txt +66 -66
  4. data/README.ja.rdoc +4 -0
  5. data/README.rdoc +31 -3
  6. data/Rakefile +111 -135
  7. data/bin/nokogiri +1 -2
  8. data/ext/nokogiri/extconf.rb +9 -3
  9. data/ext/nokogiri/nokogiri.c +21 -3
  10. data/ext/nokogiri/nokogiri.h +0 -2
  11. data/ext/nokogiri/xml_node.c +0 -6
  12. data/ext/nokogiri/xml_relax_ng.c +0 -7
  13. data/ext/nokogiri/xml_sax_parser.c +9 -4
  14. data/ext/nokogiri/xslt_stylesheet.c +5 -1
  15. data/lib/nokogiri.rb +19 -25
  16. data/lib/nokogiri/1.8/nokogiri.so +0 -0
  17. data/lib/nokogiri/1.9/nokogiri.so +0 -0
  18. data/lib/nokogiri/css.rb +0 -1
  19. data/lib/nokogiri/html.rb +1 -0
  20. data/lib/nokogiri/html/document.rb +9 -2
  21. data/lib/nokogiri/html/element_description_defaults.rb +671 -0
  22. data/lib/nokogiri/version.rb +76 -31
  23. data/lib/nokogiri/xml/attribute_decl.rb +1 -1
  24. data/lib/nokogiri/xml/builder.rb +7 -0
  25. data/lib/nokogiri/xml/document.rb +17 -1
  26. data/lib/nokogiri/xml/document_fragment.rb +14 -0
  27. data/lib/nokogiri/xml/dtd.rb +1 -1
  28. data/lib/nokogiri/xml/element_decl.rb +1 -1
  29. data/lib/nokogiri/xml/entity_decl.rb +1 -1
  30. data/lib/nokogiri/xml/node.rb +39 -15
  31. data/lib/nokogiri/xml/node/save_options.rb +14 -5
  32. data/lib/nokogiri/xml/node_set.rb +7 -0
  33. data/lib/nokogiri/xml/reader.rb +2 -2
  34. data/lib/nokogiri/xml/sax/document.rb +2 -2
  35. data/lib/nokogiri/xslt/stylesheet.rb +1 -1
  36. data/nokogiri_help_responses.md +40 -0
  37. data/tasks/cross_compile.rb +134 -155
  38. data/tasks/nokogiri.org.rb +18 -0
  39. data/tasks/test.rb +2 -2
  40. data/test/files/metacharset.html +10 -0
  41. data/test/files/noencoding.html +47 -0
  42. data/test/helper.rb +2 -1
  43. data/test/html/sax/test_parser.rb +22 -5
  44. data/test/html/test_document.rb +21 -2
  45. data/test/html/test_document_encoding.rb +9 -1
  46. data/test/html/test_document_fragment.rb +5 -3
  47. data/test/html/test_element_description.rb +4 -2
  48. data/test/test_memory_leak.rb +4 -39
  49. data/test/test_nokogiri.rb +14 -20
  50. data/test/test_reader.rb +12 -8
  51. data/test/xml/node/test_save_options.rb +10 -2
  52. data/test/xml/sax/test_parser.rb +14 -7
  53. data/test/xml/test_attribute_decl.rb +7 -3
  54. data/test/xml/test_builder.rb +17 -0
  55. data/test/xml/test_document.rb +31 -4
  56. data/test/xml/test_dtd.rb +13 -3
  57. data/test/xml/test_element_content.rb +1 -1
  58. data/test/xml/test_element_decl.rb +1 -1
  59. data/test/xml/test_entity_decl.rb +12 -10
  60. data/test/xml/test_namespace.rb +7 -5
  61. data/test/xml/test_node.rb +21 -10
  62. data/test/xml/test_node_reparenting.rb +16 -3
  63. data/test/xml/test_node_set.rb +34 -0
  64. data/test/xslt/test_custom_functions.rb +2 -2
  65. data/test/xslt/test_exception_handling.rb +37 -0
  66. metadata +110 -88
  67. data/lib/nokogiri/ffi/encoding_handler.rb +0 -42
  68. data/lib/nokogiri/ffi/html/document.rb +0 -28
  69. data/lib/nokogiri/ffi/html/element_description.rb +0 -81
  70. data/lib/nokogiri/ffi/html/entity_lookup.rb +0 -16
  71. data/lib/nokogiri/ffi/html/sax/parser_context.rb +0 -38
  72. data/lib/nokogiri/ffi/io_callbacks.rb +0 -42
  73. data/lib/nokogiri/ffi/libxml.rb +0 -420
  74. data/lib/nokogiri/ffi/structs/common_node.rb +0 -38
  75. data/lib/nokogiri/ffi/structs/html_elem_desc.rb +0 -24
  76. data/lib/nokogiri/ffi/structs/html_entity_desc.rb +0 -13
  77. data/lib/nokogiri/ffi/structs/xml_alloc.rb +0 -16
  78. data/lib/nokogiri/ffi/structs/xml_attr.rb +0 -20
  79. data/lib/nokogiri/ffi/structs/xml_attribute.rb +0 -27
  80. data/lib/nokogiri/ffi/structs/xml_buffer.rb +0 -16
  81. data/lib/nokogiri/ffi/structs/xml_char_encoding_handler.rb +0 -11
  82. data/lib/nokogiri/ffi/structs/xml_document.rb +0 -117
  83. data/lib/nokogiri/ffi/structs/xml_dtd.rb +0 -28
  84. data/lib/nokogiri/ffi/structs/xml_element.rb +0 -26
  85. data/lib/nokogiri/ffi/structs/xml_element_content.rb +0 -17
  86. data/lib/nokogiri/ffi/structs/xml_entity.rb +0 -32
  87. data/lib/nokogiri/ffi/structs/xml_enumeration.rb +0 -12
  88. data/lib/nokogiri/ffi/structs/xml_node.rb +0 -28
  89. data/lib/nokogiri/ffi/structs/xml_node_set.rb +0 -53
  90. data/lib/nokogiri/ffi/structs/xml_notation.rb +0 -11
  91. data/lib/nokogiri/ffi/structs/xml_ns.rb +0 -15
  92. data/lib/nokogiri/ffi/structs/xml_parser_context.rb +0 -20
  93. data/lib/nokogiri/ffi/structs/xml_parser_input.rb +0 -19
  94. data/lib/nokogiri/ffi/structs/xml_relax_ng.rb +0 -14
  95. data/lib/nokogiri/ffi/structs/xml_sax_handler.rb +0 -51
  96. data/lib/nokogiri/ffi/structs/xml_sax_push_parser_context.rb +0 -124
  97. data/lib/nokogiri/ffi/structs/xml_schema.rb +0 -13
  98. data/lib/nokogiri/ffi/structs/xml_syntax_error.rb +0 -31
  99. data/lib/nokogiri/ffi/structs/xml_text_reader.rb +0 -12
  100. data/lib/nokogiri/ffi/structs/xml_xpath_context.rb +0 -38
  101. data/lib/nokogiri/ffi/structs/xml_xpath_object.rb +0 -35
  102. data/lib/nokogiri/ffi/structs/xml_xpath_parser_context.rb +0 -20
  103. data/lib/nokogiri/ffi/structs/xslt_stylesheet.rb +0 -13
  104. data/lib/nokogiri/ffi/weak_bucket.rb +0 -40
  105. data/lib/nokogiri/ffi/xml/attr.rb +0 -41
  106. data/lib/nokogiri/ffi/xml/attribute_decl.rb +0 -27
  107. data/lib/nokogiri/ffi/xml/cdata.rb +0 -19
  108. data/lib/nokogiri/ffi/xml/comment.rb +0 -18
  109. data/lib/nokogiri/ffi/xml/document.rb +0 -174
  110. data/lib/nokogiri/ffi/xml/document_fragment.rb +0 -21
  111. data/lib/nokogiri/ffi/xml/dtd.rb +0 -67
  112. data/lib/nokogiri/ffi/xml/element_content.rb +0 -43
  113. data/lib/nokogiri/ffi/xml/element_decl.rb +0 -19
  114. data/lib/nokogiri/ffi/xml/entity_decl.rb +0 -36
  115. data/lib/nokogiri/ffi/xml/entity_reference.rb +0 -19
  116. data/lib/nokogiri/ffi/xml/namespace.rb +0 -44
  117. data/lib/nokogiri/ffi/xml/node.rb +0 -559
  118. data/lib/nokogiri/ffi/xml/node_set.rb +0 -150
  119. data/lib/nokogiri/ffi/xml/processing_instruction.rb +0 -20
  120. data/lib/nokogiri/ffi/xml/reader.rb +0 -236
  121. data/lib/nokogiri/ffi/xml/relax_ng.rb +0 -85
  122. data/lib/nokogiri/ffi/xml/sax/parser.rb +0 -143
  123. data/lib/nokogiri/ffi/xml/sax/parser_context.rb +0 -79
  124. data/lib/nokogiri/ffi/xml/sax/push_parser.rb +0 -51
  125. data/lib/nokogiri/ffi/xml/schema.rb +0 -109
  126. data/lib/nokogiri/ffi/xml/syntax_error.rb +0 -98
  127. data/lib/nokogiri/ffi/xml/text.rb +0 -18
  128. data/lib/nokogiri/ffi/xml/xpath.rb +0 -9
  129. data/lib/nokogiri/ffi/xml/xpath_context.rb +0 -153
  130. data/lib/nokogiri/ffi/xslt/stylesheet.rb +0 -77
  131. data/lib/nokogiri/version_warning.rb +0 -14
  132. data/test/ffi/test_document.rb +0 -35
@@ -1,18 +0,0 @@
1
- module Nokogiri
2
- module XML
3
- class Text < CharacterData
4
-
5
- def self.new(string, document, *rest) # :nodoc:
6
- node_ptr = LibXML.xmlNewText(string)
7
- node_cstruct = LibXML::XmlNode.new(node_ptr)
8
- node_cstruct[:doc] = document.cstruct[:doc]
9
-
10
- node = Node.wrap(node_cstruct, self)
11
- node.send :initialize, string, document, *rest
12
- yield node if block_given?
13
- node
14
- end
15
-
16
- end
17
- end
18
- end
@@ -1,9 +0,0 @@
1
- module Nokogiri
2
- module XML
3
- class XPath
4
-
5
- attr_accessor :cstruct # :nodoc:
6
-
7
- end
8
- end
9
- end
@@ -1,153 +0,0 @@
1
- module Nokogiri
2
- module XML
3
- class XPathContext
4
-
5
- attr_accessor :cstruct # :nodoc:
6
-
7
- def register_ns(prefix, uri) # :nodoc:
8
- LibXML.xmlXPathRegisterNs(cstruct, prefix, uri)
9
- end
10
-
11
- def register_variable(name, value) # :nodoc:
12
- xml_value = LibXML.xmlXPathNewCString(value);
13
- LibXML.xmlXPathRegisterVariable(cstruct, name, xml_value);
14
- end
15
-
16
- def evaluate(search_path, xpath_handler=nil) # :nodoc:
17
- lookup = nil # to keep lambda in scope long enough to avoid a possible GC tragedy
18
- query = search_path.to_s
19
-
20
- if xpath_handler
21
- lookup = lambda do |ctx, name, uri|
22
- return nil unless xpath_handler.respond_to?(name)
23
- ruby_funcall name, xpath_handler
24
- end
25
- LibXML.xmlXPathRegisterFuncLookup(cstruct, lookup, nil);
26
- end
27
-
28
- exception_handler = lambda do |ctx, error|
29
- raise XPath::SyntaxError.wrap(error)
30
- end
31
- LibXML.xmlResetLastError()
32
- LibXML.xmlSetStructuredErrorFunc(nil, exception_handler)
33
-
34
- generic_exception_handler = lambda do |ctx, msg|
35
- raise RuntimeError.new(msg) # TODO: varargs
36
- end
37
- LibXML.xmlSetGenericErrorFunc(nil, generic_exception_handler)
38
-
39
- xpath_ptr = LibXML.xmlXPathEvalExpression(query, cstruct)
40
-
41
- LibXML.xmlSetStructuredErrorFunc(nil, nil)
42
- LibXML.xmlSetGenericErrorFunc(nil, nil)
43
-
44
- if xpath_ptr.null?
45
- error = LibXML.xmlGetLastError()
46
- raise XPath::SyntaxError.wrap(error)
47
- end
48
-
49
- xpath = XML::XPath.new
50
- xpath.cstruct = LibXML::XmlXpathObject.new(xpath_ptr)
51
- xpath.document = cstruct.document.ruby_doc
52
-
53
- case xpath.cstruct[:type]
54
- when LibXML::XmlXpathObject::XPATH_NODESET
55
- if xpath.cstruct[:nodesetval].null?
56
- NodeSet.new(xpath.document)
57
- else
58
- NodeSet.wrap(xpath.cstruct[:nodesetval], xpath.document)
59
- end
60
- when LibXML::XmlXpathObject::XPATH_STRING
61
- xpath.cstruct[:stringval]
62
- when LibXML::XmlXpathObject::XPATH_NUMBER
63
- xpath.cstruct[:floatval]
64
- when LibXML::XmlXpathObject::XPATH_BOOLEAN
65
- 0 != xpath.cstruct[:boolval]
66
- else
67
- NodeSet.new(xpath.document)
68
- end
69
- end
70
-
71
- def self.new(node) # :nodoc:
72
- LibXML.xmlXPathInit()
73
-
74
- ptr = LibXML.xmlXPathNewContext(node.cstruct[:doc])
75
-
76
- ctx = allocate
77
- ctx.cstruct = LibXML::XmlXpathContext.new(ptr)
78
- ctx.cstruct[:node] = node.cstruct
79
- ctx
80
- end
81
-
82
- private
83
-
84
- #
85
- # returns a lambda that will call the handler function with marshalled parameters
86
- #
87
- def ruby_funcall(name, xpath_handler) # :nodoc:
88
- lambda do |ctx, nargs|
89
- parser_context = LibXML::XmlXpathParserContext.new(ctx)
90
- context_cstruct = parser_context.context
91
- document = context_cstruct.document.ruby_doc
92
-
93
- params = []
94
-
95
- nargs.times do |j|
96
- obj = LibXML::XmlXpathObject.new(LibXML.valuePop(ctx))
97
- case obj[:type]
98
- when LibXML::XmlXpathObject::XPATH_STRING
99
- params.unshift obj[:stringval]
100
- when LibXML::XmlXpathObject::XPATH_BOOLEAN
101
- params.unshift obj[:boolval] == 1
102
- when LibXML::XmlXpathObject::XPATH_NUMBER
103
- params.unshift obj[:floatval]
104
- when LibXML::XmlXpathObject::XPATH_NODESET
105
- params.unshift NodeSet.wrap(obj[:nodesetval], document)
106
- else
107
- char_ptr = params.unshift LibXML.xmlXPathCastToString(obj)
108
- string = char_ptr.read_string
109
- LibXML.xmlFree(char_ptr)
110
- string
111
- end
112
- end
113
-
114
- result = xpath_handler.send(name, *params)
115
-
116
- case result.class.to_s
117
- when Fixnum.to_s, Float.to_s, Bignum.to_s
118
- LibXML.xmlXPathReturnNumber(ctx, result)
119
- when String.to_s
120
- LibXML.xmlXPathReturnString(
121
- ctx,
122
- LibXML.xmlXPathWrapCString(result)
123
- )
124
- when TrueClass.to_s
125
- LibXML.xmlXPathReturnTrue(ctx)
126
- when FalseClass.to_s
127
- LibXML.xmlXPathReturnFalse(ctx)
128
- when NilClass.to_s
129
- ;
130
- when Array.to_s
131
- node_set = XML::NodeSet.new(document, result)
132
- LibXML.xmlXPathReturnNodeSet(
133
- ctx,
134
- LibXML.xmlXPathNodeSetMerge(nil, node_set.cstruct)
135
- )
136
- else
137
- if result.is_a?(XML::NodeSet)
138
- LibXML.xmlXPathReturnNodeSet(
139
- ctx,
140
- LibXML.xmlXPathNodeSetMerge(nil, result.cstruct)
141
- )
142
- else
143
- raise RuntimeError.new("Invalid return type #{result.class.inspect}")
144
- end
145
- end
146
-
147
- nil
148
- end # lambda
149
- end # ruby_funcall
150
-
151
- end
152
- end
153
- end
@@ -1,77 +0,0 @@
1
- module Nokogiri
2
- module XSLT
3
- @modules = {}
4
-
5
- @method_caller = lambda do |context, nargs|
6
- # TODO
7
- end
8
-
9
- @init_func = lambda do |context, uri|
10
- klass = @modules[uri]
11
- klass.instance_methods(false).each do |method_name|
12
- LibXML.xsltRegisterExtFunction(context, method_name, uri, @method_caller)
13
- end
14
- klass.new
15
- end
16
-
17
- @shutdown_func = lambda do |context, uri, data|
18
- end
19
-
20
- def self.register(uri, klass) # :nodoc:
21
- raise NotImplementedError.new("sorry, you should implement me.")
22
- end
23
-
24
- class Stylesheet
25
-
26
- attr_accessor :cstruct # :nodoc:
27
-
28
- def self.parse_stylesheet_doc(document) # :nodoc:
29
- LibXML.exsltRegisterAll
30
-
31
- generic_exception_handler = lambda do |ctx, msg|
32
- raise RuntimeError.new(msg) # TODO: varargs
33
- end
34
- LibXML.xsltSetGenericErrorFunc(nil, generic_exception_handler)
35
-
36
- ss = LibXML.xsltParseStylesheetDoc(LibXML.xmlCopyDoc(document.cstruct, 1)) # 1 => recursive
37
-
38
- LibXML.xsltSetGenericErrorFunc(nil, nil)
39
-
40
- obj = allocate
41
- obj.cstruct = LibXML::XsltStylesheet.new(ss)
42
- obj
43
- end
44
-
45
- def serialize(document) # :nodoc:
46
- buf_ptr = FFI::Buffer.new :pointer
47
- buf_len = FFI::Buffer.new :int
48
- LibXML.xsltSaveResultToString(buf_ptr, buf_len, document.cstruct, cstruct)
49
- buf = Nokogiri::LibXML::XmlAlloc.new(buf_ptr.get_pointer(0))
50
- buf.pointer.read_string(buf_len.get_int(0))
51
- end
52
-
53
- def transform(document, params=[]) # :nodoc:
54
- unless document.kind_of? Nokogiri::XML::Document
55
- raise ArgumentError, "argument must be a Nokogiri::XML::Document"
56
- end
57
-
58
- params = params.to_a.flatten if params.is_a?(Hash)
59
- raise(TypeError) unless params.is_a?(Array)
60
-
61
- param_arr = FFI::MemoryPointer.new(:pointer, params.length + 1, false)
62
-
63
- # Keep the MemoryPointer instances alive until after the call
64
- ptrs = params.map { |param | FFI::MemoryPointer.from_string(param.to_s) }
65
- param_arr.put_array_of_pointer(0, ptrs)
66
-
67
- # Terminate the list with a NULL pointer
68
- param_arr.put_pointer(LibXML.pointer_offset(params.length), nil)
69
-
70
- ptr = LibXML.xsltApplyStylesheet(cstruct, document.cstruct, param_arr)
71
- raise(RuntimeError, "could not perform xslt transform on document") if ptr.null?
72
-
73
- XML::Document.wrap(ptr)
74
- end
75
- end
76
- end
77
- end
@@ -1,14 +0,0 @@
1
- module Nokogiri
2
- if self.is_2_6_16?
3
- VERSION_INFO['warnings'] << "libxml 2.6.16 is old and buggy."
4
- if !defined?(I_KNOW_I_AM_USING_AN_OLD_AND_BUGGY_VERSION_OF_LIBXML2)
5
- warn <<-eom
6
- HI. You're using libxml2 version 2.6.16 which is over 4 years old and has
7
- plenty of bugs. We suggest that for maximum HTML/XML parsing pleasure, you
8
- upgrade your version of libxml2 and re-install nokogiri. If you like using
9
- libxml2 version 2.6.16, but don't like this warning, please define the constant
10
- I_KNOW_I_AM_USING_AN_OLD_AND_BUGGY_VERSION_OF_LIBXML2 before requring nokogiri.
11
- eom
12
- end
13
- end
14
- end
@@ -1,35 +0,0 @@
1
- require "helper"
2
-
3
- if defined?(Nokogiri::LibXML)
4
-
5
- class FFI::TestDocument < Nokogiri::TestCase
6
-
7
- def test_ruby_doc_reflection
8
- doc = Nokogiri::XML("<root><foo>foo</foo></root>")
9
- assert_equal doc, doc.cstruct.ruby_doc
10
- end
11
-
12
- def test_ruby_doc_setter
13
- doc = Nokogiri::XML("<root><foo>foo</foo></root>")
14
- foo = "foobar"
15
- doc.cstruct.ruby_doc = foo
16
- assert_equal foo, doc.cstruct.ruby_doc
17
- end
18
-
19
- def test_unlinked_nodes
20
- doc = Nokogiri::XML("<root><foo>foo</foo></root>")
21
- assert_instance_of Nokogiri::LibXML::XmlNodeSetCast, doc.cstruct.unlinked_nodes
22
- end
23
-
24
- def test_unlinked_nodes_contains_unlinked_nodes
25
- doc = Nokogiri::XML("<root><foo>foo</foo></root>")
26
- node = doc.xpath('//foo').first
27
- assert_equal 0, doc.cstruct.unlinked_nodes[:nodeNr]
28
- node.unlink
29
- assert_equal 1, doc.cstruct.unlinked_nodes[:nodeNr]
30
- assert_equal node.cstruct.pointer, doc.cstruct.unlinked_nodes[:nodeTab].get_pointer(0)
31
- end
32
-
33
- end
34
-
35
- end