Skip to content

Commit

Permalink
CSS: Fixed url() containing "@" (#2272)
Browse files Browse the repository at this point in the history
This fixes URLs that contain the "@" character.
  • Loading branch information
RunDevelopment authored Mar 26, 2020
1 parent 57eebce commit 504a63b
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
1 change: 1 addition & 0 deletions components/prism-css.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
},
'url': {
pattern: RegExp('url\\((?:' + string.source + '|[^\n\r()]*)\\)', 'i'),
greedy: true,
inside: {
'function': /^url/i,
'punctuation': /^\(|\)$/
Expand Down
2 changes: 1 addition & 1 deletion components/prism-css.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions prism.js
Original file line number Diff line number Diff line change
Expand Up @@ -863,6 +863,7 @@ Prism.languages.svg = Prism.languages.markup;
},
'url': {
pattern: RegExp('url\\((?:' + string.source + '|[^\n\r()]*)\\)', 'i'),
greedy: true,
inside: {
'function': /^url/i,
'punctuation': /^\(|\)$/
Expand Down
23 changes: 23 additions & 0 deletions tests/languages/css/url_feature.test
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ bar.png')
url("foo\
bar.png")

@import url("https://cdn.jsdelivr.net/npm/prismj1.19.0/themes/prism-dark.css");
@import url("https://cdn.jsdelivr.net/npm/prismjs/themes/prism-dark.css");

----------------------------------------------------

[
Expand Down Expand Up @@ -38,6 +41,26 @@ bar.png")
["punctuation", "("],
"\"foo\\\r\nbar.png\"",
["punctuation", ")"]
]],
["atrule", [
["rule", "@import"],
["url", [
["function", "url"],
["punctuation", "("],
"\"https://cdn.jsdelivr.net/npm/prismj1.19.0/themes/prism-dark.css\"",
["punctuation", ")"]
]],
["punctuation", ";"]
]],
["atrule", [
["rule", "@import"],
["url", [
["function", "url"],
["punctuation", "("],
"\"https://cdn.jsdelivr.net/npm/prismjs/themes/prism-dark.css\"",
["punctuation", ")"]
]],
["punctuation", ";"]
]]
]

Expand Down

0 comments on commit 504a63b

Please sign in to comment.