Skip to content

Commit

Permalink
Attempt to pass through input that we can't make sense of
Browse files Browse the repository at this point in the history
Fixes #301
  • Loading branch information
bitwiseman committed Oct 2, 2014
1 parent 52a591f commit c13efe3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
7 changes: 7 additions & 0 deletions js/lib/beautify-html.js
Original file line number Diff line number Diff line change
Expand Up @@ -811,6 +811,13 @@
}
multi_parser.current_mode = 'TAG';
break;
default:
// We should not be getting here but we don't want to drop input on the floor
// Just output the text and move on
if (multi_parser.token_text !== '') {
multi_parser.print_token(multi_parser.token_text);
}
break;
}
multi_parser.last_token = multi_parser.token_type;
multi_parser.last_text = multi_parser.token_text;
Expand Down
7 changes: 6 additions & 1 deletion js/test/beautify-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -1839,7 +1839,12 @@ function run_beautifier_tests(test_obj, Urlencoded, js_beautify, html_beautify,


opts.end_with_newline = false;
test_fragment('<head>\n' +
// error cases need love too
bth('<img title="Bad food!" src="foo.jpg" alt="Evil" ">');
bth("<!-- don't blow up if a comment is not complete");

test_fragment(
'<head>\n' +
' <script>\n' +
' mocha.setup("bdd");\n' +
' </script>\n' +
Expand Down

0 comments on commit c13efe3

Please sign in to comment.