Merge pull request #435 from sveltejs/unclosed-script-infinite-loop

Prevent unclosed <script> causing infinite loop
pull/438/head
Rich Harris 9 years ago committed by GitHub
commit 213c986b80

@ -7,6 +7,8 @@ export default function readScript ( parser, start, attributes ) {
const scriptStart = parser.index;
const scriptEnd = parser.template.indexOf( scriptClosingTag, scriptStart );
if ( scriptEnd === -1 ) parser.error( `<script> must have a closing tag` );
const source = spaces( scriptStart ) + parser.template.slice( scriptStart, scriptEnd );
parser.index = scriptEnd + scriptClosingTag.length;

@ -1,15 +1,16 @@
import assert from 'assert';
import * as fs from 'fs';
import { svelte, exists } from '../helpers.js';
import { svelte } from '../helpers.js';
describe( 'parse', () => {
fs.readdirSync( 'test/parser/samples' ).forEach( dir => {
if ( dir[0] === '.' ) return;
const solo = exists( `test/parser/samples/${dir}/solo` );
// add .solo to a sample directory name to only run that test
const solo = /\.solo$/.test( dir );
if ( solo && process.env.CI ) {
throw new Error( 'Forgot to remove `solo: true` from test' );
throw new Error( `Forgot to remove '.solo' from test parser/samples/${dir}` );
}
( solo ? it.only : it )( dir, () => {

@ -0,0 +1,8 @@
{
"message": "<script> must have a closing tag",
"loc": {
"line": 3,
"column": 8
},
"pos": 34
}

@ -0,0 +1,3 @@
<h1>Hello {{name}}!</h1>
<script>
Loading…
Cancel
Save