Skip to content

Commit

Permalink
fixed deep recursion warnings in Mojo::DOM and Mojo::DOM::HTML
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Jul 13, 2014
1 parent c27c103 commit 9c54f98
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions Changes
@@ -1,5 +1,6 @@

5.14 2014-07-14
- Fixed deep recursion warnings in Mojo::DOM and Mojo::DOM::HTML. (jberger)

5.13 2014-07-13
- Added json_like, json_message_like, json_message_unlike and json_unlike
Expand Down
1 change: 1 addition & 0 deletions lib/Mojo/DOM.pm
Expand Up @@ -325,6 +325,7 @@ sub _text {
# Nested tag
my $content = '';
if ($type eq 'tag' && $recurse) {
no warnings 'recursion';
$content = _text([_nodes($n)], 1, _trim($n, $trim));
}

Expand Down
1 change: 1 addition & 0 deletions lib/Mojo/DOM/HTML.pm
Expand Up @@ -261,6 +261,7 @@ sub _render {
}

# Render whole tree
no warnings 'recursion';
$result .= _render($tree->[$_], $xml)
for ($type eq 'root' ? 1 : 4) .. $#$tree;

Expand Down
9 changes: 7 additions & 2 deletions t/mojo/dom.t
Expand Up @@ -2363,8 +2363,13 @@ is $dom->tree->[5][1], ' HTML4 ', 'right comment';
is $dom->tree->[7][1], ' bad idea -- HTML4 ', 'right comment';

# Huge number of attributes
my $huge = '<div ' . ('a=b ' x 32768) . '>Test</div>';
$dom = Mojo::DOM->new($huge);
$dom = Mojo::DOM->new('<div ' . ('a=b ' x 32768) . '>Test</div>');
is $dom->at('div[a=b]')->text, 'Test', 'right text';

# Huge number of nested tags
my $huge = ('<a>' x 100) . 'works' . ('</a>' x 100);
$dom = Mojo::DOM->new($huge);
is $dom->all_text, 'works', 'right text';
is "$dom", $huge, 'right result';

done_testing();

0 comments on commit 9c54f98

Please sign in to comment.