mirror of https://github.com/sveltejs/svelte
fix: parser error when using semicolon inside quotes in style (#10221)
* fix error when using semicolon inside quotes in style * refactor to include { like in the original code * simplified version of regex Co-authored-by: navorite <navorite@gmail.com> * add changeset * add changeset * add test * Update .changeset/seven-hornets-smile.md Co-authored-by: navorite <navorite@gmail.com> * undo demo.css change * fix support-font-face test not passing * add double quotes * beef up test * robustify parsing * Update .changeset/seven-hornets-smile.md --------- Co-authored-by: navorite <navorite@gmail.com> Co-authored-by: Rogerio Luiz Aques de Amorim <Rogerio Amorim> Co-authored-by: Rich Harris <rich.harris@vercel.com> Co-authored-by: Rich Harris <hello@rich-harris.dev>pull/10304/head
parent
f7cc8cb263
commit
a58d93f8bf
@ -0,0 +1,5 @@
|
||||
---
|
||||
"svelte": patch
|
||||
---
|
||||
|
||||
fix: correctly parse at-rules containing special characters in strings
|
@ -0,0 +1,10 @@
|
||||
<h1>
|
||||
Semicolon inside quotes
|
||||
</h1>
|
||||
<style>
|
||||
@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@400;700&display=swap");
|
||||
h1 {
|
||||
font-weight: bold;
|
||||
background: url("whatever");
|
||||
}
|
||||
</style>
|
@ -0,0 +1,107 @@
|
||||
{
|
||||
"css": {
|
||||
"type": "Style",
|
||||
"start": 36,
|
||||
"end": 205,
|
||||
"attributes": [],
|
||||
"children": [
|
||||
{
|
||||
"type": "Atrule",
|
||||
"start": 45,
|
||||
"end": 135,
|
||||
"name": "import",
|
||||
"prelude": "url(\"https://fonts.googleapis.com/css2?family=Poppins:wght@400;700&display=swap\")",
|
||||
"block": null
|
||||
},
|
||||
{
|
||||
"type": "Rule",
|
||||
"prelude": {
|
||||
"type": "SelectorList",
|
||||
"start": 137,
|
||||
"end": 139,
|
||||
"children": [
|
||||
{
|
||||
"type": "Selector",
|
||||
"start": 137,
|
||||
"end": 139,
|
||||
"children": [
|
||||
{
|
||||
"type": "TypeSelector",
|
||||
"name": "h1",
|
||||
"start": 137,
|
||||
"end": 139
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"block": {
|
||||
"type": "Block",
|
||||
"start": 140,
|
||||
"end": 196,
|
||||
"children": [
|
||||
{
|
||||
"type": "Declaration",
|
||||
"start": 144,
|
||||
"end": 161,
|
||||
"property": "font-weight",
|
||||
"value": "bold"
|
||||
},
|
||||
{
|
||||
"type": "Declaration",
|
||||
"start": 165,
|
||||
"end": 192,
|
||||
"property": "background",
|
||||
"value": "url(\"whatever\")"
|
||||
}
|
||||
]
|
||||
},
|
||||
"start": 137,
|
||||
"end": 196
|
||||
}
|
||||
],
|
||||
"content": {
|
||||
"start": 43,
|
||||
"end": 197,
|
||||
"styles": "\n\t@import url(\"https://fonts.googleapis.com/css2?family=Poppins:wght@400;700&display=swap\");\n\th1 {\n\t\tfont-weight: bold;\n\t\tbackground: url(\"whatever\");\n\t}\n"
|
||||
}
|
||||
},
|
||||
"js": [],
|
||||
"start": 0,
|
||||
"end": 35,
|
||||
"type": "Root",
|
||||
"fragment": {
|
||||
"type": "Fragment",
|
||||
"nodes": [
|
||||
{
|
||||
"type": "RegularElement",
|
||||
"start": 0,
|
||||
"end": 35,
|
||||
"name": "h1",
|
||||
"attributes": [],
|
||||
"fragment": {
|
||||
"type": "Fragment",
|
||||
"nodes": [
|
||||
{
|
||||
"type": "Text",
|
||||
"start": 4,
|
||||
"end": 30,
|
||||
"raw": "\n\tSemicolon inside quotes\n",
|
||||
"data": "\n\tSemicolon inside quotes\n"
|
||||
}
|
||||
],
|
||||
"transparent": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Text",
|
||||
"start": 35,
|
||||
"end": 36,
|
||||
"raw": "\n",
|
||||
"data": "\n"
|
||||
}
|
||||
],
|
||||
"transparent": false
|
||||
},
|
||||
"options": null
|
||||
}
|
Loading…
Reference in new issue