mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 22:02:55 +01:00
Better cover invalid script/style tags (Microsoft/monaco-editor#412)
This commit is contained in:
parent
d475297526
commit
3e7008e334
4 changed files with 16 additions and 0 deletions
|
|
@ -118,6 +118,7 @@ export const language = <ILanguage>{
|
||||||
scriptAfterType: [
|
scriptAfterType: [
|
||||||
[/\{\{/, { token: '@rematch', switchTo: '@handlebarsInSimpleState.scriptAfterType' }],
|
[/\{\{/, { token: '@rematch', switchTo: '@handlebarsInSimpleState.scriptAfterType' }],
|
||||||
[/=/, 'delimiter', '@scriptAfterTypeEquals'],
|
[/=/, 'delimiter', '@scriptAfterTypeEquals'],
|
||||||
|
[/>/, { token: 'delimiter.html', next: '@scriptEmbedded.text/javascript', nextEmbedded: 'text/javascript' }], // cover invalid e.g. <script type>
|
||||||
[/[ \t\r\n]+/], // whitespace
|
[/[ \t\r\n]+/], // whitespace
|
||||||
[/<\/script\s*>/, { token: '@rematch', next: '@pop' }]
|
[/<\/script\s*>/, { token: '@rematch', next: '@pop' }]
|
||||||
],
|
],
|
||||||
|
|
@ -127,6 +128,7 @@ export const language = <ILanguage>{
|
||||||
[/\{\{/, { token: '@rematch', switchTo: '@handlebarsInSimpleState.scriptAfterTypeEquals' }],
|
[/\{\{/, { token: '@rematch', switchTo: '@handlebarsInSimpleState.scriptAfterTypeEquals' }],
|
||||||
[/"([^"]*)"/, { token: 'attribute.value', switchTo: '@scriptWithCustomType.$1' }],
|
[/"([^"]*)"/, { token: 'attribute.value', switchTo: '@scriptWithCustomType.$1' }],
|
||||||
[/'([^']*)'/, { token: 'attribute.value', switchTo: '@scriptWithCustomType.$1' }],
|
[/'([^']*)'/, { token: 'attribute.value', switchTo: '@scriptWithCustomType.$1' }],
|
||||||
|
[/>/, { token: 'delimiter.html', next: '@scriptEmbedded.text/javascript', nextEmbedded: 'text/javascript' }], // cover invalid e.g. <script type=>
|
||||||
[/[ \t\r\n]+/], // whitespace
|
[/[ \t\r\n]+/], // whitespace
|
||||||
[/<\/script\s*>/, { token: '@rematch', next: '@pop' }]
|
[/<\/script\s*>/, { token: '@rematch', next: '@pop' }]
|
||||||
],
|
],
|
||||||
|
|
@ -170,6 +172,7 @@ export const language = <ILanguage>{
|
||||||
styleAfterType: [
|
styleAfterType: [
|
||||||
[/\{\{/, { token: '@rematch', switchTo: '@handlebarsInSimpleState.styleAfterType' }],
|
[/\{\{/, { token: '@rematch', switchTo: '@handlebarsInSimpleState.styleAfterType' }],
|
||||||
[/=/, 'delimiter', '@styleAfterTypeEquals'],
|
[/=/, 'delimiter', '@styleAfterTypeEquals'],
|
||||||
|
[/>/, { token: 'delimiter.html', next: '@styleEmbedded.text/css', nextEmbedded: 'text/css' }], // cover invalid e.g. <style type>
|
||||||
[/[ \t\r\n]+/], // whitespace
|
[/[ \t\r\n]+/], // whitespace
|
||||||
[/<\/style\s*>/, { token: '@rematch', next: '@pop' }]
|
[/<\/style\s*>/, { token: '@rematch', next: '@pop' }]
|
||||||
],
|
],
|
||||||
|
|
@ -179,6 +182,7 @@ export const language = <ILanguage>{
|
||||||
[/\{\{/, { token: '@rematch', switchTo: '@handlebarsInSimpleState.styleAfterTypeEquals' }],
|
[/\{\{/, { token: '@rematch', switchTo: '@handlebarsInSimpleState.styleAfterTypeEquals' }],
|
||||||
[/"([^"]*)"/, { token: 'attribute.value', switchTo: '@styleWithCustomType.$1' }],
|
[/"([^"]*)"/, { token: 'attribute.value', switchTo: '@styleWithCustomType.$1' }],
|
||||||
[/'([^']*)'/, { token: 'attribute.value', switchTo: '@styleWithCustomType.$1' }],
|
[/'([^']*)'/, { token: 'attribute.value', switchTo: '@styleWithCustomType.$1' }],
|
||||||
|
[/>/, { token: 'delimiter.html', next: '@styleEmbedded.text/css', nextEmbedded: 'text/css' }], // cover invalid e.g. <style type=>
|
||||||
[/[ \t\r\n]+/], // whitespace
|
[/[ \t\r\n]+/], // whitespace
|
||||||
[/<\/style\s*>/, { token: '@rematch', next: '@pop' }]
|
[/<\/style\s*>/, { token: '@rematch', next: '@pop' }]
|
||||||
],
|
],
|
||||||
|
|
|
||||||
|
|
@ -113,6 +113,7 @@ export const language = <ILanguage>{
|
||||||
// After <script ... type
|
// After <script ... type
|
||||||
scriptAfterType: [
|
scriptAfterType: [
|
||||||
[/=/, 'delimiter', '@scriptAfterTypeEquals'],
|
[/=/, 'delimiter', '@scriptAfterTypeEquals'],
|
||||||
|
[/>/, { token: 'delimiter', next: '@scriptEmbedded', nextEmbedded: 'text/javascript' }], // cover invalid e.g. <script type>
|
||||||
[/[ \t\r\n]+/], // whitespace
|
[/[ \t\r\n]+/], // whitespace
|
||||||
[/<\/script\s*>/, { token: '@rematch', next: '@pop' }]
|
[/<\/script\s*>/, { token: '@rematch', next: '@pop' }]
|
||||||
],
|
],
|
||||||
|
|
@ -121,6 +122,7 @@ export const language = <ILanguage>{
|
||||||
scriptAfterTypeEquals: [
|
scriptAfterTypeEquals: [
|
||||||
[/"([^"]*)"/, { token: 'attribute.value', switchTo: '@scriptWithCustomType.$1' }],
|
[/"([^"]*)"/, { token: 'attribute.value', switchTo: '@scriptWithCustomType.$1' }],
|
||||||
[/'([^']*)'/, { token: 'attribute.value', switchTo: '@scriptWithCustomType.$1' }],
|
[/'([^']*)'/, { token: 'attribute.value', switchTo: '@scriptWithCustomType.$1' }],
|
||||||
|
[/>/, { token: 'delimiter', next: '@scriptEmbedded', nextEmbedded: 'text/javascript' }], // cover invalid e.g. <script type=>
|
||||||
[/[ \t\r\n]+/], // whitespace
|
[/[ \t\r\n]+/], // whitespace
|
||||||
[/<\/script\s*>/, { token: '@rematch', next: '@pop' }]
|
[/<\/script\s*>/, { token: '@rematch', next: '@pop' }]
|
||||||
],
|
],
|
||||||
|
|
@ -161,6 +163,7 @@ export const language = <ILanguage>{
|
||||||
// After <style ... type
|
// After <style ... type
|
||||||
styleAfterType: [
|
styleAfterType: [
|
||||||
[/=/, 'delimiter', '@styleAfterTypeEquals'],
|
[/=/, 'delimiter', '@styleAfterTypeEquals'],
|
||||||
|
[/>/, { token: 'delimiter', next: '@styleEmbedded', nextEmbedded: 'text/css' }], // cover invalid e.g. <style type>
|
||||||
[/[ \t\r\n]+/], // whitespace
|
[/[ \t\r\n]+/], // whitespace
|
||||||
[/<\/style\s*>/, { token: '@rematch', next: '@pop' }]
|
[/<\/style\s*>/, { token: '@rematch', next: '@pop' }]
|
||||||
],
|
],
|
||||||
|
|
@ -169,6 +172,7 @@ export const language = <ILanguage>{
|
||||||
styleAfterTypeEquals: [
|
styleAfterTypeEquals: [
|
||||||
[/"([^"]*)"/, { token: 'attribute.value', switchTo: '@styleWithCustomType.$1' }],
|
[/"([^"]*)"/, { token: 'attribute.value', switchTo: '@styleWithCustomType.$1' }],
|
||||||
[/'([^']*)'/, { token: 'attribute.value', switchTo: '@styleWithCustomType.$1' }],
|
[/'([^']*)'/, { token: 'attribute.value', switchTo: '@styleWithCustomType.$1' }],
|
||||||
|
[/>/, { token: 'delimiter', next: '@styleEmbedded', nextEmbedded: 'text/css' }], // cover invalid e.g. <style type=>
|
||||||
[/[ \t\r\n]+/], // whitespace
|
[/[ \t\r\n]+/], // whitespace
|
||||||
[/<\/style\s*>/, { token: '@rematch', next: '@pop' }]
|
[/<\/style\s*>/, { token: '@rematch', next: '@pop' }]
|
||||||
],
|
],
|
||||||
|
|
|
||||||
|
|
@ -93,6 +93,7 @@ export const language = <ILanguage>{
|
||||||
scriptAfterType: [
|
scriptAfterType: [
|
||||||
[/<\?((php)|=)?/, { token: '@rematch', switchTo: '@phpInSimpleState.scriptAfterType' }],
|
[/<\?((php)|=)?/, { token: '@rematch', switchTo: '@phpInSimpleState.scriptAfterType' }],
|
||||||
[/=/, 'delimiter', '@scriptAfterTypeEquals'],
|
[/=/, 'delimiter', '@scriptAfterTypeEquals'],
|
||||||
|
[/>/, { token: 'delimiter.html', next: '@scriptEmbedded.text/javascript', nextEmbedded: 'text/javascript' }], // cover invalid e.g. <script type>
|
||||||
[/[ \t\r\n]+/], // whitespace
|
[/[ \t\r\n]+/], // whitespace
|
||||||
[/<\/script\s*>/, { token: '@rematch', next: '@pop' }]
|
[/<\/script\s*>/, { token: '@rematch', next: '@pop' }]
|
||||||
],
|
],
|
||||||
|
|
@ -102,6 +103,7 @@ export const language = <ILanguage>{
|
||||||
[/<\?((php)|=)?/, { token: '@rematch', switchTo: '@phpInSimpleState.scriptAfterTypeEquals' }],
|
[/<\?((php)|=)?/, { token: '@rematch', switchTo: '@phpInSimpleState.scriptAfterTypeEquals' }],
|
||||||
[/"([^"]*)"/, { token: 'attribute.value', switchTo: '@scriptWithCustomType.$1' }],
|
[/"([^"]*)"/, { token: 'attribute.value', switchTo: '@scriptWithCustomType.$1' }],
|
||||||
[/'([^']*)'/, { token: 'attribute.value', switchTo: '@scriptWithCustomType.$1' }],
|
[/'([^']*)'/, { token: 'attribute.value', switchTo: '@scriptWithCustomType.$1' }],
|
||||||
|
[/>/, { token: 'delimiter.html', next: '@scriptEmbedded.text/javascript', nextEmbedded: 'text/javascript' }], // cover invalid e.g. <script type=>
|
||||||
[/[ \t\r\n]+/], // whitespace
|
[/[ \t\r\n]+/], // whitespace
|
||||||
[/<\/script\s*>/, { token: '@rematch', next: '@pop' }]
|
[/<\/script\s*>/, { token: '@rematch', next: '@pop' }]
|
||||||
],
|
],
|
||||||
|
|
@ -145,6 +147,7 @@ export const language = <ILanguage>{
|
||||||
styleAfterType: [
|
styleAfterType: [
|
||||||
[/<\?((php)|=)?/, { token: '@rematch', switchTo: '@phpInSimpleState.styleAfterType' }],
|
[/<\?((php)|=)?/, { token: '@rematch', switchTo: '@phpInSimpleState.styleAfterType' }],
|
||||||
[/=/, 'delimiter', '@styleAfterTypeEquals'],
|
[/=/, 'delimiter', '@styleAfterTypeEquals'],
|
||||||
|
[/>/, { token: 'delimiter.html', next: '@styleEmbedded.text/css', nextEmbedded: 'text/css' }], // cover invalid e.g. <style type>
|
||||||
[/[ \t\r\n]+/], // whitespace
|
[/[ \t\r\n]+/], // whitespace
|
||||||
[/<\/style\s*>/, { token: '@rematch', next: '@pop' }]
|
[/<\/style\s*>/, { token: '@rematch', next: '@pop' }]
|
||||||
],
|
],
|
||||||
|
|
@ -154,6 +157,7 @@ export const language = <ILanguage>{
|
||||||
[/<\?((php)|=)?/, { token: '@rematch', switchTo: '@phpInSimpleState.styleAfterTypeEquals' }],
|
[/<\?((php)|=)?/, { token: '@rematch', switchTo: '@phpInSimpleState.styleAfterTypeEquals' }],
|
||||||
[/"([^"]*)"/, { token: 'attribute.value', switchTo: '@styleWithCustomType.$1' }],
|
[/"([^"]*)"/, { token: 'attribute.value', switchTo: '@styleWithCustomType.$1' }],
|
||||||
[/'([^']*)'/, { token: 'attribute.value', switchTo: '@styleWithCustomType.$1' }],
|
[/'([^']*)'/, { token: 'attribute.value', switchTo: '@styleWithCustomType.$1' }],
|
||||||
|
[/>/, { token: 'delimiter.html', next: '@styleEmbedded.text/css', nextEmbedded: 'text/css' }], // cover invalid e.g. <style type=>
|
||||||
[/[ \t\r\n]+/], // whitespace
|
[/[ \t\r\n]+/], // whitespace
|
||||||
[/<\/style\s*>/, { token: '@rematch', next: '@pop' }]
|
[/<\/style\s*>/, { token: '@rematch', next: '@pop' }]
|
||||||
],
|
],
|
||||||
|
|
|
||||||
|
|
@ -118,6 +118,7 @@ export const language = <ILanguage>{
|
||||||
scriptAfterType: [
|
scriptAfterType: [
|
||||||
[/@[^@]/, { token: '@rematch', switchTo: '@razorInSimpleState.scriptAfterType' }],
|
[/@[^@]/, { token: '@rematch', switchTo: '@razorInSimpleState.scriptAfterType' }],
|
||||||
[/=/, 'delimiter', '@scriptAfterTypeEquals'],
|
[/=/, 'delimiter', '@scriptAfterTypeEquals'],
|
||||||
|
[/>/, { token: 'delimiter.html', next: '@scriptEmbedded.text/javascript', nextEmbedded: 'text/javascript' }], // cover invalid e.g. <script type>
|
||||||
[/[ \t\r\n]+/], // whitespace
|
[/[ \t\r\n]+/], // whitespace
|
||||||
[/<\/script\s*>/, { token: '@rematch', next: '@pop' }]
|
[/<\/script\s*>/, { token: '@rematch', next: '@pop' }]
|
||||||
],
|
],
|
||||||
|
|
@ -127,6 +128,7 @@ export const language = <ILanguage>{
|
||||||
[/@[^@]/, { token: '@rematch', switchTo: '@razorInSimpleState.scriptAfterTypeEquals' }],
|
[/@[^@]/, { token: '@rematch', switchTo: '@razorInSimpleState.scriptAfterTypeEquals' }],
|
||||||
[/"([^"]*)"/, { token: 'attribute.value', switchTo: '@scriptWithCustomType.$1' }],
|
[/"([^"]*)"/, { token: 'attribute.value', switchTo: '@scriptWithCustomType.$1' }],
|
||||||
[/'([^']*)'/, { token: 'attribute.value', switchTo: '@scriptWithCustomType.$1' }],
|
[/'([^']*)'/, { token: 'attribute.value', switchTo: '@scriptWithCustomType.$1' }],
|
||||||
|
[/>/, { token: 'delimiter.html', next: '@scriptEmbedded.text/javascript', nextEmbedded: 'text/javascript' }], // cover invalid e.g. <script type=>
|
||||||
[/[ \t\r\n]+/], // whitespace
|
[/[ \t\r\n]+/], // whitespace
|
||||||
[/<\/script\s*>/, { token: '@rematch', next: '@pop' }]
|
[/<\/script\s*>/, { token: '@rematch', next: '@pop' }]
|
||||||
],
|
],
|
||||||
|
|
@ -170,6 +172,7 @@ export const language = <ILanguage>{
|
||||||
styleAfterType: [
|
styleAfterType: [
|
||||||
[/@[^@]/, { token: '@rematch', switchTo: '@razorInSimpleState.styleAfterType' }],
|
[/@[^@]/, { token: '@rematch', switchTo: '@razorInSimpleState.styleAfterType' }],
|
||||||
[/=/, 'delimiter', '@styleAfterTypeEquals'],
|
[/=/, 'delimiter', '@styleAfterTypeEquals'],
|
||||||
|
[/>/, { token: 'delimiter.html', next: '@styleEmbedded.text/css', nextEmbedded: 'text/css' }], // cover invalid e.g. <style type>
|
||||||
[/[ \t\r\n]+/], // whitespace
|
[/[ \t\r\n]+/], // whitespace
|
||||||
[/<\/style\s*>/, { token: '@rematch', next: '@pop' }]
|
[/<\/style\s*>/, { token: '@rematch', next: '@pop' }]
|
||||||
],
|
],
|
||||||
|
|
@ -179,6 +182,7 @@ export const language = <ILanguage>{
|
||||||
[/@[^@]/, { token: '@rematch', switchTo: '@razorInSimpleState.styleAfterTypeEquals' }],
|
[/@[^@]/, { token: '@rematch', switchTo: '@razorInSimpleState.styleAfterTypeEquals' }],
|
||||||
[/"([^"]*)"/, { token: 'attribute.value', switchTo: '@styleWithCustomType.$1' }],
|
[/"([^"]*)"/, { token: 'attribute.value', switchTo: '@styleWithCustomType.$1' }],
|
||||||
[/'([^']*)'/, { token: 'attribute.value', switchTo: '@styleWithCustomType.$1' }],
|
[/'([^']*)'/, { token: 'attribute.value', switchTo: '@styleWithCustomType.$1' }],
|
||||||
|
[/>/, { token: 'delimiter.html', next: '@styleEmbedded.text/css', nextEmbedded: 'text/css' }], // cover invalid e.g. <style type=>
|
||||||
[/[ \t\r\n]+/], // whitespace
|
[/[ \t\r\n]+/], // whitespace
|
||||||
[/<\/style\s*>/, { token: '@rematch', next: '@pop' }]
|
[/<\/style\s*>/, { token: '@rematch', next: '@pop' }]
|
||||||
],
|
],
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue