Skip to content
This repository was archived by the owner on Sep 22, 2022. It is now read-only.

Commit 8fa0ce6

Browse files
koddssonkeithamus
andcommitted
Escape HTML in description
Co-authored-by: Keith Cirkel <[email protected]>
1 parent 1b529eb commit 8fa0ce6

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# &lt;details-dialog&gt; element
22

3-
A modal dialog opened with a <details> button.
3+
A modal dialog opened with a &lt;details&gt; button.
44

55
## Installation
66
Available on [npm](https://www.npmjs.com/) as [**@github/details-dialog-element**](https://www.npmjs.com/package/@github/details-dialog-element).

cem-plugin-readme.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ Include with a script tag:
4343
\`\`\``
4444
}
4545

46+
const escapeHTML = (html) => {
47+
return html.replaceAll('&', '&amp;').replaceAll('<', '&lt;').replaceAll('>', '&gt;').replaceAll('"', '&quot;').replaceAll("'", '&#039;');
48+
}
49+
4650
export function readme(options) {
4751
const {filename = 'README.md', exclude = [], title, preamble, footer} = options ?? {}
4852

@@ -53,7 +57,7 @@ export function readme(options) {
5357
async packageLinkPhase({customElementsManifest}) {
5458
const content = [
5559
`# ${title || generateTitle({packageJson})}`,
56-
packageJson.description,
60+
escapeHTML(packageJson.description),
5761
preamble,
5862
generateInstallationInstructions({packageJson}),
5963
`## Usage`,

0 commit comments

Comments
 (0)