Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix entity specs #2652

Merged
merged 2 commits into from Nov 20, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Renderer.js
Expand Up @@ -32,7 +32,7 @@ export class Renderer {

return '<pre><code class="'
+ this.options.langPrefix
+ escape(lang, true)
+ escape(lang)
+ '">'
+ (escaped ? code : escape(code, true))
+ '</code></pre>\n';
Expand Down Expand Up @@ -170,7 +170,7 @@ export class Renderer {
if (href === null) {
return text;
}
let out = '<a href="' + escape(href) + '"';
let out = '<a href="' + href + '"';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about when href contains a ' or "?

Do we have a test for that?

Copy link
Member Author

@UziTech UziTech Nov 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (title) {
out += ' title="' + title + '"';
}
Expand Down
6 changes: 3 additions & 3 deletions src/helpers.js
Expand Up @@ -2,9 +2,9 @@
* Helpers
*/
const escapeTest = /[&<>"']/;
const escapeReplace = /[&<>"']/g;
const escapeTestNoEncode = /[<>"']|&(?!#?\w+;)/;
const escapeReplaceNoEncode = /[<>"']|&(?!#?\w+;)/g;
const escapeReplace = new RegExp(escapeTest.source, 'g');
const escapeTestNoEncode = /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-f0-9]{1,6}|\w+);)/;
Fixed Show fixed Hide fixed
const escapeReplaceNoEncode = new RegExp(escapeTestNoEncode.source, 'g');
const escapeReplacements = {
'&': '&amp;',
'<': '&lt;',
Expand Down
6 changes: 2 additions & 4 deletions test/specs/commonmark/commonmark.0.30.json
Expand Up @@ -221,8 +221,7 @@
"example": 28,
"start_line": 691,
"end_line": 701,
"section": "Entity and numeric character references",
"shouldFail": true
"section": "Entity and numeric character references"
},
{
"markdown": "&copy\n",
Expand Down Expand Up @@ -272,8 +271,7 @@
"example": 34,
"start_line": 752,
"end_line": 759,
"section": "Entity and numeric character references",
"shouldFail": true
"section": "Entity and numeric character references"
},
{
"markdown": "`f&ouml;&ouml;`\n",
Expand Down
6 changes: 2 additions & 4 deletions test/specs/gfm/commonmark.0.30.json
Expand Up @@ -221,8 +221,7 @@
"example": 28,
"start_line": 691,
"end_line": 701,
"section": "Entity and numeric character references",
"shouldFail": true
"section": "Entity and numeric character references"
},
{
"markdown": "&copy\n",
Expand Down Expand Up @@ -272,8 +271,7 @@
"example": 34,
"start_line": 752,
"end_line": 759,
"section": "Entity and numeric character references",
"shouldFail": true
"section": "Entity and numeric character references"
},
{
"markdown": "`f&ouml;&ouml;`\n",
Expand Down