Skip to content

Commit

Permalink
fix: escape html string @ inline code
Browse files Browse the repository at this point in the history
  • Loading branch information
duckimann committed Apr 21, 2024
1 parent faf0918 commit ae8caa6
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/components/EditorMarkdownIt.vue
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,17 @@ export default {
}
},
escapeHTML(string) {
return string.replace(/[^\u0030-\u0039\u0041-\u005A\u0061-\u007A]/g, function(char) {
return `&#${char.charCodeAt()}`
})
},
setInlineCodeRule() {
const editorInstance = this
this.md.renderer.rules.code_inline = function(tokens, idx, options, env, self) {
const token = tokens[idx]
return '<code class="inline-code">' + token.content + '</code>'
return '<code class="inline-code">' + editorInstance.escapeHTML(token.content) + '</code>'
}
},
},
Expand Down

0 comments on commit ae8caa6

Please sign in to comment.