hpricot 0.8.5-i386-mswin32 → 0.8.6-i386-mswin32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -375,18 +375,30 @@ public class HpricotScanService implements BasicLibraryService {
375
375
  if(!S.xml) {
376
376
  IRubyObject match = runtime.getNil(), e = S.focus;
377
377
  while(e != S.doc) {
378
- IRubyObject hEC = H_ELE_GET(e, H_ELE_EC);
379
- if(hEC instanceof RubyHash) {
380
- IRubyObject has = ((RubyHash)hEC).op_aref(scanner.ctx, name);
381
- if(!has.isNil()) {
382
- if(has == runtime.getTrue()) {
383
- if(match.isNil()) {
384
- match = e;
378
+ if (ec.isNil()) {
379
+ // Anything can contain an unknown element
380
+ if(match.isNil()) {
381
+ match = e;
382
+ }
383
+ } else {
384
+ IRubyObject hEC = H_ELE_GET(e, H_ELE_EC);
385
+ if(hEC instanceof RubyHash) {
386
+ IRubyObject has = ((RubyHash)hEC).op_aref(scanner.ctx, name);
387
+ if(!has.isNil()) {
388
+ if(has == runtime.getTrue()) {
389
+ if(match.isNil()) {
390
+ match = e;
391
+ }
392
+ } else if(has == x.symAllow) {
393
+ match = S.focus;
394
+ } else if(has == x.symDeny) {
395
+ match = runtime.getNil();
385
396
  }
386
- } else if(has == x.symAllow) {
387
- match = S.focus;
388
- } else if(has == x.symDeny) {
389
- match = runtime.getNil();
397
+ }
398
+ } else {
399
+ // Unknown elements can contain anything
400
+ if(match.isNil()) {
401
+ match = e;
390
402
  }
391
403
  }
392
404
  }
@@ -356,23 +356,32 @@ rb_hpricot_token(hpricot_state *S, VALUE sym, VALUE tag, VALUE attr,
356
356
  VALUE match = Qnil, e = S->focus;
357
357
  while (e != S->doc)
358
358
  {
359
- VALUE hEC = H_ELE_GET(e, H_ELE_EC);
360
-
361
- if (TYPE(hEC) == T_HASH)
362
- {
363
- VALUE has = rb_hash_lookup(hEC, name);
364
- if (has != Qnil) {
365
- if (has == Qtrue) {
366
- if (match == Qnil)
367
- match = e;
368
- } else if (has == symAllow) {
369
- match = S->focus;
370
- } else if (has == symDeny) {
371
- match = Qnil;
359
+ if (ec == Qnil) {
360
+ // anything can contain unknown elements
361
+ if (match == Qnil)
362
+ match = e;
363
+ } else {
364
+ VALUE hEC = H_ELE_GET(e, H_ELE_EC);
365
+
366
+ if (TYPE(hEC) == T_HASH)
367
+ {
368
+ VALUE has = rb_hash_lookup(hEC, name);
369
+ if (has != Qnil) {
370
+ if (has == Qtrue) {
371
+ if (match == Qnil)
372
+ match = e;
373
+ } else if (has == symAllow) {
374
+ match = S->focus;
375
+ } else if (has == symDeny) {
376
+ match = Qnil;
377
+ }
372
378
  }
379
+ } else {
380
+ // Unknown elements can contain anything
381
+ if (match == Qnil)
382
+ match = e;
373
383
  }
374
384
  }
375
-
376
385
  e = H_ELE_GET(e, H_ELE_PARENT);
377
386
  }
378
387
 
Binary file
Binary file
@@ -475,4 +475,22 @@ class TestParser < Test::Unit::TestCase
475
475
  assert_nothing_raised {Hpricot.parse(TestFiles::BNQT)}
476
476
  end
477
477
 
478
+ def test_unknown_tag
479
+ header = <<-edoc
480
+ <header id="htest">
481
+ <div id="dtest">blah</div>
482
+ </header>
483
+ edoc
484
+ doc = Hpricot(<<-edoc)
485
+ <div>#{header}</div>
486
+ edoc
487
+ assert_equal header.chomp, (doc/"#htest").to_html
488
+ end
489
+
490
+ def test_nested_unknown_tags
491
+ header =
492
+ %(<header id="htest"><div id="dtest"><nav>blah</nav></div></header>)
493
+ doc = Hpricot(%(<div>#{header}</div>))
494
+ assert_equal header.chomp, (doc/"#htest").to_html
495
+ end
478
496
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hpricot
3
3
  version: !ruby/object:Gem::Version
4
- hash: 53
4
+ hash: 51
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 8
9
- - 5
10
- version: 0.8.5
9
+ - 6
10
+ version: 0.8.6
11
11
  platform: i386-mswin32
12
12
  authors:
13
13
  - why the lucky stiff
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-11-29 00:00:00 Z
18
+ date: 2012-01-17 00:00:00 Z
19
19
  dependencies: []
20
20
 
21
21
  description: a swift, liberal HTML parser with a fantastic library