Skip to content

Commit

Permalink
Merge pull request #471 from Infocatcher/correct-script-type
Browse files Browse the repository at this point in the history
Add support for more <script> types
  • Loading branch information
bitwiseman committed May 22, 2014
2 parents 9d0ecf8 + 0823ed8 commit 219a44e
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
8 changes: 7 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,13 @@
P_A_C_K_E_R.run_tests(st);
Urlencoded.run_tests(st);
MyObfuscate.run_tests(st);
var results = st.results_raw().replace(/ /g, '&nbsp;').replace(/\r/g, '·').replace(/\n/g, '<br>');
var results = st.results_raw()
.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/ /g, '&nbsp;')
.replace(/\r/g, '·')
.replace(/\n/g, '<br>');
$('#testresults').html(results).show();
}

Expand Down
3 changes: 2 additions & 1 deletion js/lib/beautify-html.js
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,8 @@
}
} else if (tag_check === 'script' &&
(tag_complete.search('type') === -1 ||
(tag_complete.search('type') > -1 && tag_complete.search('text/javascript') > -1))) {
(tag_complete.search('type') > -1 &&
tag_complete.search(/\b(text|application)\/(x-)?(javascript|ecmascript|jscript|livescript)/) > -1))) {
if (!peek) {
this.record_tag(tag_check);
this.tag_type = 'SCRIPT';
Expand Down
20 changes: 20 additions & 0 deletions js/test/beautify-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -1719,6 +1719,26 @@ function run_beautifier_tests(test_obj, Urlencoded, js_beautify, html_beautify,
'<script type="text/javascript">\n' +
' var foo = "bar";\n' +
'</script>');
bth('<script type="application/javascript">var foo = "bar";</script>',
'<script type="application/javascript">\n' +
' var foo = "bar";\n' +
'</script>');
bth('<script type="application/javascript;version=1.8">var foo = "bar";</script>',
'<script type="application/javascript;version=1.8">\n' +
' var foo = "bar";\n' +
'</script>');
bth('<script type="application/x-javascript">var foo = "bar";</script>',
'<script type="application/x-javascript">\n' +
' var foo = "bar";\n' +
'</script>');
bth('<script type="application/ecmascript">var foo = "bar";</script>',
'<script type="application/ecmascript">\n' +
' var foo = "bar";\n' +
'</script>');
bth('<script type="text/javascript1.5">var foo = "bar";</script>',
'<script type="text/javascript1.5">\n' +
' var foo = "bar";\n' +
'</script>');
bth('<script>var foo = "bar";</script>',
'<script>\n' +
' var foo = "bar";\n' +
Expand Down

0 comments on commit 219a44e

Please sign in to comment.