This repository was archived by the owner on Apr 22, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +20
-6
lines changed
Expand file tree Collapse file tree 1 file changed +20
-6
lines changed Original file line number Diff line number Diff line change @@ -976,11 +976,21 @@ function PR_splitSourceNodes(tokens) {
976976
977977 var sourceChunks = null ;
978978
979- for ( var ci = 0 , nc = tokens . length ; ci < nc ; ++ ci ) {
980- var tok = tokens [ ci ] ;
981- if ( null == tok . style ) {
982- tokens . push ( tok ) ;
983- continue ;
979+ for ( var ci = 0 , nc = tokens . length ; /* break below */ ; ++ ci ) {
980+ var tok ;
981+
982+ if ( ci < nc ) {
983+ tok = tokens [ ci ] ;
984+ if ( null == tok . style ) {
985+ tokens . push ( tok ) ;
986+ continue ;
987+ }
988+ } else if ( ! endScriptTag ) {
989+ break ;
990+ } else {
991+ // else pretend there's an end tag so we can gracefully handle
992+ // unclosed source blocks
993+ tok = new PR_Token ( '' , null ) ;
984994 }
985995
986996 var s = tok . token ;
@@ -1038,6 +1048,9 @@ function PR_splitSourceNodes(tokens) {
10381048 } else {
10391049 tokensOut . push ( tok ) ;
10401050 }
1051+ } else if ( ci >= nc ) {
1052+ // force the token to close
1053+ endTok = tok ;
10411054 } else {
10421055 if ( sourceChunks ) {
10431056 sourceChunks . push ( tok ) ;
@@ -1056,7 +1069,7 @@ function PR_splitSourceNodes(tokens) {
10561069 tokensOut . push ( new PR_Token ( '</span>' , null ) ) ;
10571070 sourceChunks = null ;
10581071 }
1059- tokensOut . push ( endTok ) ;
1072+ if ( endTok . token ) { tokensOut . push ( endTok ) ; }
10601073 endScriptTag = null ;
10611074 }
10621075 } else {
@@ -1278,6 +1291,7 @@ function PR_lexOne(s) {
12781291 break ;
12791292 }
12801293 }
1294+
12811295 return isMarkup ? PR_lexMarkup ( chunks ) : PR_lexSource ( chunks ) ;
12821296}
12831297
You can’t perform that action at this time.
0 commit comments