nokogiri 1.6.7.2-java → 1.6.8-java

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 (107) hide show
  1. checksums.yaml +4 -4
  2. data/.cross_rubies +2 -0
  3. data/.travis.yml +19 -9
  4. data/CHANGELOG.rdoc +73 -5
  5. data/CONTRIBUTING.md +42 -0
  6. data/Gemfile +10 -9
  7. data/LICENSE.txt +1 -1
  8. data/Manifest.txt +7 -2
  9. data/README.md +23 -27
  10. data/ROADMAP.md +11 -1
  11. data/Rakefile +36 -17
  12. data/bin/nokogiri +2 -2
  13. data/dependencies.yml +29 -4
  14. data/ext/java/nokogiri/HtmlElementDescription.java +5 -2
  15. data/ext/java/nokogiri/NokogiriService.java +19 -0
  16. data/ext/java/nokogiri/XmlAttr.java +3 -1
  17. data/ext/java/nokogiri/XmlDocumentFragment.java +0 -14
  18. data/ext/java/nokogiri/XmlNode.java +106 -63
  19. data/ext/java/nokogiri/XmlXpathContext.java +12 -12
  20. data/ext/java/nokogiri/XsltStylesheet.java +11 -4
  21. data/ext/java/nokogiri/internals/HtmlDomParserContext.java +8 -1
  22. data/ext/java/nokogiri/internals/NokogiriErrorHandler.java +1 -2
  23. data/ext/java/nokogiri/internals/NokogiriHelpers.java +7 -7
  24. data/ext/java/nokogiri/internals/NokogiriNonStrictErrorHandler4NekoHtml.java +1 -1
  25. data/ext/java/nokogiri/internals/NokogiriStrictErrorHandler.java +0 -1
  26. data/ext/java/nokogiri/internals/NokogiriXsltErrorListener.java +3 -3
  27. data/ext/java/nokogiri/internals/ParserContext.java +4 -0
  28. data/ext/java/nokogiri/internals/SaveContextVisitor.java +18 -13
  29. data/ext/nokogiri/extconf.rb +163 -79
  30. data/ext/nokogiri/html_document.c +6 -6
  31. data/ext/nokogiri/html_element_description.c +1 -1
  32. data/ext/nokogiri/html_entity_lookup.c +1 -1
  33. data/ext/nokogiri/html_sax_parser_context.c +4 -4
  34. data/ext/nokogiri/html_sax_push_parser.c +2 -2
  35. data/ext/nokogiri/nokogiri.c +0 -7
  36. data/ext/nokogiri/nokogiri.h +1 -34
  37. data/ext/nokogiri/xml_attr.c +2 -2
  38. data/ext/nokogiri/xml_comment.c +1 -1
  39. data/ext/nokogiri/xml_document.c +20 -22
  40. data/ext/nokogiri/xml_encoding_handler.c +3 -3
  41. data/ext/nokogiri/xml_entity_reference.c +1 -1
  42. data/ext/nokogiri/xml_namespace.c +56 -17
  43. data/ext/nokogiri/xml_node.c +73 -67
  44. data/ext/nokogiri/xml_node_set.c +164 -146
  45. data/ext/nokogiri/xml_node_set.h +3 -4
  46. data/ext/nokogiri/xml_processing_instruction.c +2 -2
  47. data/ext/nokogiri/xml_reader.c +5 -18
  48. data/ext/nokogiri/xml_sax_parser.c +9 -12
  49. data/ext/nokogiri/xml_sax_parser_context.c +1 -1
  50. data/ext/nokogiri/xml_sax_push_parser.c +1 -1
  51. data/ext/nokogiri/xml_schema.c +1 -1
  52. data/ext/nokogiri/xml_syntax_error.c +0 -4
  53. data/ext/nokogiri/xml_syntax_error.h +0 -1
  54. data/ext/nokogiri/xml_text.c +1 -1
  55. data/ext/nokogiri/xml_xpath_context.c +15 -24
  56. data/ext/nokogiri/xslt_stylesheet.c +6 -6
  57. data/lib/nekohtml.jar +0 -0
  58. data/lib/nokogiri.rb +14 -7
  59. data/lib/nokogiri/css/parser.rb +8 -2
  60. data/lib/nokogiri/css/parser.y +7 -2
  61. data/lib/nokogiri/html/document.rb +4 -2
  62. data/lib/nokogiri/nokogiri.jar +0 -0
  63. data/lib/nokogiri/version.rb +1 -1
  64. data/lib/nokogiri/xml/document.rb +7 -1
  65. data/lib/nokogiri/xml/dtd.rb +4 -4
  66. data/lib/nokogiri/xml/node.rb +6 -10
  67. data/lib/nokogiri/xml/node_set.rb +3 -3
  68. data/lib/nokogiri/xml/parse_options.rb +22 -0
  69. data/lib/serializer.jar +0 -0
  70. data/lib/xalan.jar +0 -0
  71. data/lib/xercesImpl.jar +0 -0
  72. data/lib/xml-apis.jar +0 -0
  73. data/tasks/test.rb +5 -0
  74. data/test/css/test_parser.rb +7 -1
  75. data/test/files/GH_1042.html +18 -0
  76. data/test/files/namespace_pressure_test.xml +1684 -0
  77. data/test/files/tlm.html +2 -1
  78. data/test/helper.rb +4 -0
  79. data/test/html/sax/test_parser.rb +2 -2
  80. data/test/html/test_document.rb +47 -11
  81. data/test/html/test_document_encoding.rb +55 -58
  82. data/test/html/test_document_fragment.rb +27 -23
  83. data/test/html/test_node.rb +16 -0
  84. data/test/html/test_node_encoding.rb +71 -13
  85. data/test/namespaces/test_namespaces_in_parsed_doc.rb +14 -0
  86. data/test/test_css_cache.rb +1 -1
  87. data/test/test_encoding_handler.rb +2 -0
  88. data/test/test_xslt_transforms.rb +38 -3
  89. data/test/xml/sax/test_parser.rb +54 -53
  90. data/test/xml/test_document.rb +7 -2
  91. data/test/xml/test_document_encoding.rb +19 -16
  92. data/test/xml/test_document_fragment.rb +12 -0
  93. data/test/xml/test_dtd_encoding.rb +0 -2
  94. data/test/xml/test_namespace.rb +2 -2
  95. data/test/xml/test_node.rb +15 -4
  96. data/test/xml/test_node_attributes.rb +6 -0
  97. data/test/xml/test_node_encoding.rb +49 -87
  98. data/test/xml/test_node_reparenting.rb +193 -18
  99. data/test/xml/test_node_set.rb +1 -1
  100. data/test/xml/test_reader.rb +589 -0
  101. data/test/xml/test_reader_encoding.rb +100 -102
  102. data/test/xml/test_unparented_node.rb +14 -1
  103. data/test/xslt/test_exception_handling.rb +1 -1
  104. data/test_all +47 -33
  105. metadata +38 -36
  106. data/CHANGELOG.ja.rdoc +0 -1057
  107. data/test/test_reader.rb +0 -558
@@ -6,9 +6,8 @@ void init_xml_node_set();
6
6
 
7
7
  extern VALUE cNokogiriXmlNodeSet ;
8
8
  VALUE Nokogiri_wrap_xml_node_set(xmlNodeSetPtr node_set, VALUE document) ;
9
+ VALUE Nokogiri_wrap_xml_node_set_node(xmlNodePtr node, VALUE node_set) ;
10
+ VALUE Nokogiri_wrap_xml_node_set_namespace(xmlNsPtr node, VALUE node_set) ;
11
+ int Nokogiri_namespace_eh(xmlNodePtr node) ;
9
12
 
10
- typedef struct _nokogiriNodeSetTuple {
11
- xmlNodeSetPtr node_set;
12
- st_table *namespaces;
13
- } nokogiriNodeSetTuple;
14
13
  #endif
@@ -23,8 +23,8 @@ static VALUE new(int argc, VALUE *argv, VALUE klass)
23
23
 
24
24
  node = xmlNewDocPI(
25
25
  xml_doc,
26
- (const xmlChar *)StringValuePtr(name),
27
- (const xmlChar *)StringValuePtr(content)
26
+ (const xmlChar *)StringValueCStr(name),
27
+ (const xmlChar *)StringValueCStr(content)
28
28
  );
29
29
 
30
30
  nokogiri_root_node(node);
@@ -218,20 +218,7 @@ static VALUE reader_attribute(VALUE self, VALUE name)
218
218
  if(NIL_P(name)) return Qnil;
219
219
  name = StringValue(name) ;
220
220
 
221
- value = xmlTextReaderGetAttribute(reader, (xmlChar*)StringValuePtr(name));
222
- if(value == NULL) {
223
- /* this section is an attempt to workaround older versions of libxml that
224
- don't handle namespaces properly in all attribute-and-friends functions */
225
- xmlChar *prefix = NULL ;
226
- xmlChar *localname = xmlSplitQName2((xmlChar*)StringValuePtr(name), &prefix);
227
- if (localname != NULL) {
228
- value = xmlTextReaderLookupNamespace(reader, localname);
229
- xmlFree(localname) ;
230
- } else {
231
- value = xmlTextReaderLookupNamespace(reader, prefix);
232
- }
233
- xmlFree(prefix);
234
- }
221
+ value = xmlTextReaderGetAttribute(reader, (xmlChar*)StringValueCStr(name));
235
222
  if(value == NULL) return Qnil;
236
223
 
237
224
  rb_value = NOKOGIRI_STR_NEW2(value);
@@ -546,8 +533,8 @@ static VALUE from_memory(int argc, VALUE *argv, VALUE klass)
546
533
  rb_scan_args(argc, argv, "13", &rb_buffer, &rb_url, &encoding, &rb_options);
547
534
 
548
535
  if (!RTEST(rb_buffer)) rb_raise(rb_eArgError, "string cannot be nil");
549
- if (RTEST(rb_url)) c_url = StringValuePtr(rb_url);
550
- if (RTEST(encoding)) c_encoding = StringValuePtr(encoding);
536
+ if (RTEST(rb_url)) c_url = StringValueCStr(rb_url);
537
+ if (RTEST(encoding)) c_encoding = StringValueCStr(encoding);
551
538
  if (RTEST(rb_options)) c_options = (int)NUM2INT(rb_options);
552
539
 
553
540
  reader = xmlReaderForMemory(
@@ -590,8 +577,8 @@ static VALUE from_io(int argc, VALUE *argv, VALUE klass)
590
577
  rb_scan_args(argc, argv, "13", &rb_io, &rb_url, &encoding, &rb_options);
591
578
 
592
579
  if (!RTEST(rb_io)) rb_raise(rb_eArgError, "io cannot be nil");
593
- if (RTEST(rb_url)) c_url = StringValuePtr(rb_url);
594
- if (RTEST(encoding)) c_encoding = StringValuePtr(encoding);
580
+ if (RTEST(rb_url)) c_url = StringValueCStr(rb_url);
581
+ if (RTEST(encoding)) c_encoding = StringValueCStr(encoding);
595
582
  if (RTEST(rb_options)) c_options = (int)NUM2INT(rb_options);
596
583
 
597
584
  reader = xmlReaderForIO(
@@ -9,9 +9,6 @@ static ID id_comment, id_characters, id_xmldecl, id_error, id_warning;
9
9
  static ID id_cdata_block, id_cAttribute;
10
10
  static ID id_processing_instruction;
11
11
 
12
- #define STRING_OR_NULL(str) \
13
- (RTEST(str) ? StringValuePtr(str) : NULL)
14
-
15
12
  static void start_document(void * ctx)
16
13
  {
17
14
  VALUE self = NOKOGIRI_SAX_SELF(ctx);
@@ -21,16 +18,16 @@ static void start_document(void * ctx)
21
18
 
22
19
  if(NULL != ctxt && ctxt->html != 1) {
23
20
  if(ctxt->standalone != -1) { /* -1 means there was no declaration */
24
- VALUE encoding = ctxt->encoding ?
25
- NOKOGIRI_STR_NEW2(ctxt->encoding) :
26
- Qnil;
21
+ VALUE encoding = Qnil ;
22
+ if (ctxt->encoding) {
23
+ encoding = NOKOGIRI_STR_NEW2(ctxt->encoding) ;
24
+ } else if (ctxt->input && ctxt->input->encoding) {
25
+ encoding = NOKOGIRI_STR_NEW2(ctxt->input->encoding) ;
26
+ }
27
27
 
28
- VALUE version = ctxt->version ?
29
- NOKOGIRI_STR_NEW2(ctxt->version) :
30
- Qnil;
28
+ VALUE version = ctxt->version ? NOKOGIRI_STR_NEW2(ctxt->version) : Qnil;
31
29
 
32
30
  VALUE standalone = Qnil;
33
-
34
31
  switch(ctxt->standalone)
35
32
  {
36
33
  case 0:
@@ -160,7 +157,7 @@ start_element_ns (
160
157
  }
161
158
 
162
159
  /**
163
- * end_element_ns was borrowed heavily from libxml-ruby.
160
+ * end_element_ns was borrowed heavily from libxml-ruby.
164
161
  */
165
162
  static void
166
163
  end_element_ns (
@@ -172,7 +169,7 @@ end_element_ns (
172
169
  VALUE self = NOKOGIRI_SAX_SELF(ctx);
173
170
  VALUE doc = rb_iv_get(self, "@document");
174
171
 
175
- rb_funcall(doc, id_end_element_namespace, 3,
172
+ rb_funcall(doc, id_end_element_namespace, 3,
176
173
  NOKOGIRI_STR_NEW2(localname),
177
174
  RBSTR_OR_QNIL(prefix),
178
175
  RBSTR_OR_QNIL(uri)
@@ -45,7 +45,7 @@ parse_io(VALUE klass, VALUE io, VALUE encoding)
45
45
  */
46
46
  static VALUE parse_file(VALUE klass, VALUE filename)
47
47
  {
48
- xmlParserCtxtPtr ctxt = xmlCreateFileParserCtxt(StringValuePtr(filename));
48
+ xmlParserCtxtPtr ctxt = xmlCreateFileParserCtxt(StringValueCStr(filename));
49
49
  return Data_Wrap_Struct(klass, NULL, deallocate, ctxt);
50
50
  }
51
51
 
@@ -59,7 +59,7 @@ static VALUE initialize_native(VALUE self, VALUE _xml_sax, VALUE _filename)
59
59
 
60
60
  Data_Get_Struct(_xml_sax, xmlSAXHandler, sax);
61
61
 
62
- if(_filename != Qnil) filename = StringValuePtr(_filename);
62
+ if(_filename != Qnil) filename = StringValueCStr(_filename);
63
63
 
64
64
  ctx = xmlCreatePushParserCtxt(
65
65
  sax,
@@ -61,7 +61,7 @@ static VALUE validate_file(VALUE self, VALUE rb_filename)
61
61
  VALUE errors;
62
62
 
63
63
  Data_Get_Struct(self, xmlSchema, schema);
64
- filename = (const char*)StringValuePtr(rb_filename) ;
64
+ filename = (const char*)StringValueCStr(rb_filename) ;
65
65
 
66
66
  errors = rb_ary_new();
67
67
 
@@ -7,10 +7,6 @@ void Nokogiri_error_array_pusher(void * ctx, xmlErrorPtr error)
7
7
  rb_ary_push(list, Nokogiri_wrap_xml_syntax_error(error));
8
8
  }
9
9
 
10
- void Nokogiri_error_silencer(void * ctx, xmlErrorPtr error)
11
- {
12
- }
13
-
14
10
  void Nokogiri_error_raise(void * ctx, xmlErrorPtr error)
15
11
  {
16
12
  rb_exc_raise(Nokogiri_wrap_xml_syntax_error(error));
@@ -6,7 +6,6 @@
6
6
  void init_xml_syntax_error();
7
7
  VALUE Nokogiri_wrap_xml_syntax_error(xmlErrorPtr error);
8
8
  void Nokogiri_error_array_pusher(void * ctx, xmlErrorPtr error);
9
- void Nokogiri_error_silencer(void * ctx, xmlErrorPtr error);
10
9
  NORETURN(void Nokogiri_error_raise(void * ctx, xmlErrorPtr error));
11
10
 
12
11
  extern VALUE cNokogiriXmlSyntaxError;
@@ -19,7 +19,7 @@ static VALUE new(int argc, VALUE *argv, VALUE klass)
19
19
 
20
20
  Data_Get_Struct(document, xmlDoc, doc);
21
21
 
22
- node = xmlNewText((xmlChar *)StringValuePtr(string));
22
+ node = xmlNewText((xmlChar *)StringValueCStr(string));
23
23
  node->doc = doc->doc;
24
24
 
25
25
  nokogiri_root_node(node);
@@ -21,8 +21,8 @@ static VALUE register_ns(VALUE self, VALUE prefix, VALUE uri)
21
21
  Data_Get_Struct(self, xmlXPathContext, ctx);
22
22
 
23
23
  xmlXPathRegisterNs( ctx,
24
- (const xmlChar *)StringValuePtr(prefix),
25
- (const xmlChar *)StringValuePtr(uri)
24
+ (const xmlChar *)StringValueCStr(prefix),
25
+ (const xmlChar *)StringValueCStr(uri)
26
26
  );
27
27
  return self;
28
28
  }
@@ -39,10 +39,10 @@ static VALUE register_variable(VALUE self, VALUE name, VALUE value)
39
39
  xmlXPathObjectPtr xmlValue;
40
40
  Data_Get_Struct(self, xmlXPathContext, ctx);
41
41
 
42
- xmlValue = xmlXPathNewCString(StringValuePtr(value));
42
+ xmlValue = xmlXPathNewCString(StringValueCStr(value));
43
43
 
44
44
  xmlXPathRegisterVariable( ctx,
45
- (const xmlChar *)StringValuePtr(name),
45
+ (const xmlChar *)StringValueCStr(name),
46
46
  xmlValue
47
47
  );
48
48
 
@@ -57,7 +57,6 @@ void Nokogiri_marshal_xpath_funcall_and_return_values(xmlXPathParserContextPtr c
57
57
  VALUE node_set = Qnil;
58
58
  xmlNodeSetPtr xml_node_set = NULL;
59
59
  xmlXPathObjectPtr obj;
60
- nokogiriNodeSetTuple *node_set_tuple;
61
60
 
62
61
  assert(ctx->context->doc);
63
62
  assert(DOC_RUBY_OBJECT_TEST(ctx->context->doc));
@@ -109,7 +108,7 @@ void Nokogiri_marshal_xpath_funcall_and_return_values(xmlXPathParserContextPtr c
109
108
  case T_STRING:
110
109
  xmlXPathReturnString(
111
110
  ctx,
112
- xmlCharStrdup(StringValuePtr(result))
111
+ xmlCharStrdup(StringValueCStr(result))
113
112
  );
114
113
  break;
115
114
  case T_TRUE:
@@ -123,25 +122,23 @@ void Nokogiri_marshal_xpath_funcall_and_return_values(xmlXPathParserContextPtr c
123
122
  case T_ARRAY:
124
123
  {
125
124
  VALUE args[2];
126
- args[0] = doc;
127
- args[1] = result;
125
+ args[0] = doc;
126
+ args[1] = result;
128
127
  node_set = rb_class_new_instance(2, args, cNokogiriXmlNodeSet);
129
- Data_Get_Struct(node_set, nokogiriNodeSetTuple, node_set_tuple);
130
- xml_node_set = node_set_tuple->node_set;
128
+ Data_Get_Struct(node_set, xmlNodeSet, xml_node_set);
131
129
  xmlXPathReturnNodeSet(ctx, xmlXPathNodeSetMerge(NULL, xml_node_set));
132
130
  }
133
- break;
131
+ break;
134
132
  case T_DATA:
135
133
  if(rb_obj_is_kind_of(result, cNokogiriXmlNodeSet)) {
136
- Data_Get_Struct(result, nokogiriNodeSetTuple, node_set_tuple);
137
- xml_node_set = node_set_tuple->node_set;
134
+ Data_Get_Struct(result, xmlNodeSet, xml_node_set);
138
135
  /* Copy the node set, otherwise it will get GC'd. */
139
136
  xmlXPathReturnNodeSet(ctx, xmlXPathNodeSetMerge(NULL, xml_node_set));
140
137
  break;
141
138
  }
142
139
  default:
143
140
  rb_raise(rb_eRuntimeError, "Invalid return type");
144
- }
141
+ }
145
142
  }
146
143
 
147
144
  static void ruby_funcall(xmlXPathParserContextPtr ctx, int nargs)
@@ -203,7 +200,7 @@ static VALUE evaluate(int argc, VALUE *argv, VALUE self)
203
200
  if(rb_scan_args(argc, argv, "11", &search_path, &xpath_handler) == 1)
204
201
  xpath_handler = Qnil;
205
202
 
206
- query = (xmlChar *)StringValuePtr(search_path);
203
+ query = (xmlChar *)StringValueCStr(search_path);
207
204
 
208
205
  if(Qnil != xpath_handler) {
209
206
  /* FIXME: not sure if this is the correct place to shove private data. */
@@ -236,13 +233,8 @@ static VALUE evaluate(int argc, VALUE *argv, VALUE self)
236
233
  xmlFree(xpath->stringval);
237
234
  break;
238
235
  case XPATH_NODESET:
239
- if(NULL == xpath->nodesetval) {
240
- thing = Nokogiri_wrap_xml_node_set(xmlXPathNodeSetCreate(NULL),
241
- DOC_RUBY_OBJECT(ctx->doc));
242
- } else {
243
- thing = Nokogiri_wrap_xml_node_set(xpath->nodesetval,
244
- DOC_RUBY_OBJECT(ctx->doc));
245
- }
236
+ thing = Nokogiri_wrap_xml_node_set(xpath->nodesetval,
237
+ DOC_RUBY_OBJECT(ctx->doc));
246
238
  break;
247
239
  case XPATH_NUMBER:
248
240
  thing = rb_float_new(xpath->floatval);
@@ -251,8 +243,7 @@ static VALUE evaluate(int argc, VALUE *argv, VALUE self)
251
243
  thing = xpath->boolval == 1 ? Qtrue : Qfalse;
252
244
  break;
253
245
  default:
254
- thing = Nokogiri_wrap_xml_node_set(xmlXPathNodeSetCreate(NULL),
255
- DOC_RUBY_OBJECT(ctx->doc));
246
+ thing = Nokogiri_wrap_xml_node_set(NULL, DOC_RUBY_OBJECT(ctx->doc));
256
247
  }
257
248
 
258
249
  xmlXPathFreeNodeSetList(xpath);
@@ -22,7 +22,7 @@ static void dealloc(nokogiriXsltStylesheetTuple *wrapper)
22
22
  NOKOGIRI_DEBUG_START(doc);
23
23
  xsltFreeStylesheet(doc); /* commented out for now. */
24
24
  NOKOGIRI_DEBUG_END(doc);
25
-
25
+
26
26
  free(wrapper);
27
27
  }
28
28
 
@@ -47,7 +47,7 @@ VALUE Nokogiri_wrap_xslt_stylesheet(xsltStylesheetPtr ss)
47
47
 
48
48
  self = Data_Make_Struct(cNokogiriXsltStylesheet, nokogiriXsltStylesheetTuple,
49
49
  mark, dealloc, wrapper);
50
-
50
+
51
51
  ss->_private = (void *)self;
52
52
  wrapper->ss = ss;
53
53
  wrapper->func_instances = rb_ary_new();
@@ -122,7 +122,7 @@ static void swallow_superfluous_xml_errors(void * userdata, xmlErrorPtr error, .
122
122
  * returns Nokogiri::XML::Document
123
123
  *
124
124
  * Example:
125
- *
125
+ *
126
126
  * doc = Nokogiri::XML(File.read(ARGV[0]))
127
127
  * xslt = Nokogiri::XSLT(File.read(ARGV[1]))
128
128
  * puts xslt.transform(doc, ['key', 'value'])
@@ -158,7 +158,7 @@ static VALUE transform(int argc, VALUE* argv, VALUE self)
158
158
  params = calloc((size_t)param_len+1, sizeof(char*));
159
159
  for (j = 0 ; j < param_len ; j++) {
160
160
  VALUE entry = rb_ary_entry(paramobj, j);
161
- const char * ptr = StringValuePtr(entry);
161
+ const char * ptr = StringValueCStr(entry);
162
162
  params[j] = ptr;
163
163
  }
164
164
  params[param_len] = 0 ;
@@ -211,7 +211,7 @@ static void * initFunc(xsltTransformContextPtr ctxt, const xmlChar *uri)
211
211
  for(i = 0; i < RARRAY_LEN(methods); i++) {
212
212
  VALUE method_name = rb_obj_as_string(rb_ary_entry(methods, i));
213
213
  xsltRegisterExtFunction(ctxt,
214
- (unsigned char *)StringValuePtr(method_name), uri, method_caller);
214
+ (unsigned char *)StringValueCStr(method_name), uri, method_caller);
215
215
  }
216
216
 
217
217
  Data_Get_Struct(ctxt->style->_private, nokogiriXsltStylesheetTuple,
@@ -245,7 +245,7 @@ static VALUE registr(VALUE self, VALUE uri, VALUE obj)
245
245
  if(NIL_P(modules)) rb_raise(rb_eRuntimeError, "wtf! @modules isn't set");
246
246
 
247
247
  rb_hash_aset(modules, uri, obj);
248
- xsltRegisterExtModule((unsigned char *)StringValuePtr(uri), initFunc, shutdownFunc);
248
+ xsltRegisterExtModule((unsigned char *)StringValueCStr(uri), initFunc, shutdownFunc);
249
249
  return self;
250
250
  }
251
251
 
Binary file
@@ -19,6 +19,9 @@ if defined?(RUBY_ENGINE) && RUBY_ENGINE == "jruby"
19
19
  require 'nekohtml.jar'
20
20
  require 'nekodtd.jar'
21
21
  require 'xercesImpl.jar'
22
+ require 'serializer.jar'
23
+ require 'xalan.jar'
24
+ require 'xml-apis.jar'
22
25
  end
23
26
  end
24
27
 
@@ -111,15 +114,19 @@ module Nokogiri
111
114
  def Slop(*args, &block)
112
115
  Nokogiri(*args, &block).slop!
113
116
  end
117
+
118
+ def install_default_aliases
119
+ # Make sure to support some popular encoding aliases not known by
120
+ # all iconv implementations.
121
+ {
122
+ 'Windows-31J' => 'CP932', # Windows-31J is the IANA registered name of CP932.
123
+ }.each { |alias_name, name|
124
+ EncodingHandler.alias(name, alias_name) if EncodingHandler[alias_name].nil?
125
+ }
126
+ end
114
127
  end
115
128
 
116
- # Make sure to support some popular encoding aliases not known by
117
- # all iconv implementations.
118
- {
119
- 'Windows-31J' => 'CP932', # Windows-31J is the IANA registered name of CP932.
120
- }.each { |alias_name, name|
121
- EncodingHandler.alias(name, alias_name) if EncodingHandler[alias_name].nil?
122
- }
129
+ Nokogiri.install_default_aliases
123
130
  end
124
131
 
125
132
  ###
@@ -8,9 +8,15 @@ require 'racc/parser.rb'
8
8
 
9
9
 
10
10
  require 'nokogiri/css/parser_extras'
11
+
11
12
  module Nokogiri
12
13
  module CSS
13
14
  class Parser < Racc::Parser
15
+
16
+
17
+ def unescape_css_identifier(identifier)
18
+ identifier.gsub(/\\(?:([^0-9a-fA-F])|([0-9a-fA-F]{1,6})\s?)/){ |m| $1 || [$2.hex].pack('U') }
19
+ end
14
20
  ##### State transition tables begin ###
15
21
 
16
22
  racc_action_table = [
@@ -406,7 +412,7 @@ end
406
412
  # reduce 17 omitted
407
413
 
408
414
  def _reduce_18(val, _values, result)
409
- result = Node.new(:CLASS_CONDITION, [val[1]])
415
+ result = Node.new(:CLASS_CONDITION, [unescape_css_identifier(val[1])])
410
416
  result
411
417
  end
412
418
 
@@ -650,7 +656,7 @@ end
650
656
  # reduce 57 omitted
651
657
 
652
658
  def _reduce_58(val, _values, result)
653
- result = Node.new(:ID, val)
659
+ result = Node.new(:ID, [unescape_css_identifier(val.first)])
654
660
  result
655
661
  end
656
662
 
@@ -55,7 +55,7 @@ rule
55
55
  | simple_selector
56
56
  ;
57
57
  class
58
- : '.' IDENT { result = Node.new(:CLASS_CONDITION, [val[1]]) }
58
+ : '.' IDENT { result = Node.new(:CLASS_CONDITION, [unescape_css_identifier(val[1])]) }
59
59
  ;
60
60
  element_name
61
61
  : namespaced_ident
@@ -218,7 +218,7 @@ rule
218
218
  | negation
219
219
  ;
220
220
  attribute_id
221
- : HASH { result = Node.new(:ID, val) }
221
+ : HASH { result = Node.new(:ID, [unescape_css_identifier(val.first)]) }
222
222
  ;
223
223
  attrib_val_0or1
224
224
  : eql_incl_dash IDENT { result = [val.first, val[1]] }
@@ -254,3 +254,8 @@ end
254
254
 
255
255
  require 'nokogiri/css/parser_extras'
256
256
 
257
+ ---- inner
258
+
259
+ def unescape_css_identifier(identifier)
260
+ identifier.gsub(/\\(?:([^0-9a-fA-F])|([0-9a-fA-F]{1,6})\s?)/){ |m| $1 || [$2.hex].pack('U') }
261
+ end
@@ -173,7 +173,7 @@ module Nokogiri
173
173
 
174
174
  if string_or_io.respond_to?(:read)
175
175
  url ||= string_or_io.respond_to?(:path) ? string_or_io.path : nil
176
- if !encoding
176
+ unless encoding
177
177
  # Libxml2's parser has poor support for encoding
178
178
  # detection. First, it does not recognize the HTML5
179
179
  # style meta charset declaration. Secondly, even if it
@@ -196,7 +196,9 @@ module Nokogiri
196
196
  end
197
197
 
198
198
  # read_memory pukes on empty docs
199
- return new if string_or_io.nil? or string_or_io.empty?
199
+ if string_or_io.nil? or string_or_io.empty?
200
+ return encoding ? new.tap { |i| i.encoding = encoding } : new
201
+ end
200
202
 
201
203
  encoding ||= EncodingReader.detect_encoding(string_or_io)
202
204