File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ var _ = require('lodash'),
1111HtmlDiff . prototype . tokenize = function ( html ) {
1212 html = modifyHtmlAccordingToOptions ( html , this . options ) ;
1313
14- return _ . filter ( html . split ( / ( \s + | \b ) / ) ) ;
14+ return _ . filter ( html . split ( / ( [ { } : ; , < > " ' \[ \] ] | \s + ) / ) ) ;
1515} ;
1616
1717/**
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ module.exports = {
3737 var res = '<' + tagName ;
3838
3939 attrs . forEach ( function ( attr ) {
40- res += ' ' + attr . name + '="' + attr . value + '"' ;
40+ res += ' ' + attr . name + '="' + escape ( attr . value ) + '"' ;
4141 } ) ;
4242
4343 selfClosing && ( res += '/' ) ;
@@ -63,3 +63,11 @@ module.exports = {
6363 return '<!--' + text + '-->' ;
6464 }
6565} ;
66+
67+ function escape ( str ) {
68+ return String ( str )
69+ . replace ( / & / g, '&' )
70+ . replace ( / " / g, '"' )
71+ . replace ( / < / g, '<' )
72+ . replace ( / > / g, '>' ) ;
73+ }
You can’t perform that action at this time.
0 commit comments