Sublime Forum

Including other files: escape closing sequence

#1

Hi, took example from https://www.sublimetext.com/docs/3/syntax.html
and easily broke html syntax highlighting with this:

<span>
	<script>
		var a = 10;
		var oops = '</script>';
		var b = 12;
	</script>
</span>

are there any good solutions to prevent it?

0 Likes

#2

In your example, the script tag ends on the fourth line at the first </script. Everything after that is not within the script tag. The HTML syntax handles this correctly, according to the standard parsing rules defined in the HTML spec and implemented in browsers. There are some cases where the HTML syntax may not handle script tags exactly correctly, but this is not one of them.

To prevent this, don’t include the text </script inside a script tag. For instance:

<span>
	<script>
		var a = 10;
		var oops = '<'+'/script>';
		var b = 12;
	</script>
</span>
0 Likes