Browse files

Support parsing <svg>, <canvas>, etc in Goodie HTML

  • Loading branch information...
1 parent 4750116 commit 926e1424a0a89411291713bbadb466a5f778f725 @moollaza moollaza committed Jun 30, 2014
Showing with 8 additions and 5 deletions.
  1. +8 −5 lib/App/DuckPAN/Web.pm
View
13 lib/App/DuckPAN/Web.pm
@@ -292,11 +292,14 @@ sub request {
my $zci_body = $zci_container->look_down(class => 'zci__body');
# Stick the answer inside $zci_body
- $zci_body->push_content(
- $result->has_html ?
- HTML::TreeBuilder->new_from_content($result->html)->guts :
- $result->answer
- );
+ my $answer = $result->answer;
+ if ($result->has_html) {
+ my $tb = HTML::TreeBuilder->new();
+ # Specifically allow unknown tags to support <svg> and <canvas>
+ $tb->ignore_unknown(0);
+ $answer = $tb->parse_content($result->html)->guts;
+ }
+ $zci_body->push_content($answer);
my $zci_wrapper = $root->look_down(id => "zero_click_wrapper");
$zci_wrapper->insert_element($zci_container);

0 comments on commit 926e142

Please sign in to comment.