Skip to content

Commit

Permalink
Bump Playwright version to remove vulnerability
Browse files Browse the repository at this point in the history
The GitHub action workflow determined that Playwright needed to be
updated in order to reduce vulnerabilities. See:

https://github.com/chocolatey/choco-theme/actions/runs/9131946165/job/25112241220?pr=404
  • Loading branch information
st3phhays committed May 21, 2024
1 parent bc8af78 commit 35be37c
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 32 deletions.
18 changes: 16 additions & 2 deletions dist/js/design.js
Original file line number Diff line number Diff line change
Expand Up @@ -18694,9 +18694,11 @@
codeForView.forEach((el) => {
const codeOriginal = el;
const codeLanguage = codeOriginal.getAttribute("data-language");
const codeReplace = codeOriginal.getAttribute("data-replace");
let codeHighlight = "";
switch (codeLanguage) {
case "HTML":
case "Astro":
codeHighlight = "markup";
break;
case "Markdown":
Expand All @@ -18711,8 +18713,20 @@
default:
codeHighlight = "none";
}
const codeContainer = `<p class="border-top border-bottom py-2 px-3 mb-0">${codeLanguage}</p><pre class="border-0 my-0 code-static-toolbar"><code class="language-${codeHighlight} line-numbers">${escapeHTML(codeOriginal.innerHTML.trim())}</code></pre>`;
codeOriginal.insertAdjacentHTML("afterend", codeContainer);
let codeEscaped = escapeHTML(codeOriginal.innerHTML.trim());
const start2 = "&lt;";
const startSlash = `${start2}/`;
const end2 = "&gt;";
const endSlash = `/${end2}`;
const contentQuotes = /content=&quot;([^&]*)&quot;/g;
codeEscaped = codeEscaped.replaceAll(`${start2}callout`, `${start2}Callout`).replaceAll(`${startSlash}callout`, `${startSlash}Callout`).replaceAll(`${start2}collapsebutton`, `${start2}CollapseButton`).replaceAll(`${startSlash}collapsebutton`, `${startSlash}CollapseButton`).replaceAll(`${start2}iframe ratio`, `${start2}Iframe ratio`).replaceAll(`${start2}tabspanecontainer`, `${start2}TabsPaneContainer`).replaceAll(`${startSlash}tabspanecontainer`, `${startSlash}TabsPaneContainer`).replaceAll(`${start2}tabstabcontainer`, `${start2}TabsTabContainer`).replaceAll(`${start2}tabspane`, `${start2}TabsPane`).replaceAll(`${start2}xref`, `${start2}Xref`).replaceAll(`value=&quot;example-define&quot;${end2}`, `value=&quot;example-define&quot; ${endSlash}`).replaceAll(`anchor=&quot;why&quot;${end2}`, `anchor=&quot;why&quot; ${endSlash}`).replaceAll(`${startSlash}tabspane`, `${startSlash}TabsPane`).replaceAll(`content=&quot;{tabs1}&quot;${end2}`, `content=&quot;{tabs1}&quot; ${endSlash}`).replaceAll(`content=&quot;{tabs2}&quot;${end2}`, `content=&quot;{tabs2}&quot; ${endSlash}`).replaceAll(`content=&quot;{tabs3}&quot;${end2}`, `content=&quot;{tabs3}&quot; ${endSlash}`).replaceAll(`multi=&quot;version&quot;${end2}`, `multi=&quot;version&quot; ${endSlash}`).replaceAll(`${startSlash}tabstabcontainer${end2}`, "").replaceAll(`${startSlash}xref${end2}`, "").replaceAll(`${startSlash}iframe${end2}`, "").replace(contentQuotes, (match2, p1) => `content=${p1}`);
if (codeReplace !== "true") {
const codeContainer = `<p class="border-top border-bottom py-2 px-3 mb-0">${codeLanguage}</p><pre class="border-0 my-0 code-static-toolbar"><code class="language-${codeHighlight} line-numbers">${codeEscaped}</code></pre>`;
codeOriginal.insertAdjacentHTML("afterend", codeContainer);
} else {
const codeContainer = `<pre><code class="language-${codeHighlight} line-numbers">${codeEscaped}</code></pre>`;
codeOriginal.innerHTML = codeContainer;
}
});
})();

Expand Down
24 changes: 12 additions & 12 deletions dist/js/design.min.js

Large diffs are not rendered by default.

43 changes: 41 additions & 2 deletions js/src/code-copy-for-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ import { escapeHTML } from './util/functions';
codeForView.forEach(el => {
const codeOriginal = el;
const codeLanguage = codeOriginal.getAttribute('data-language');
const codeReplace = codeOriginal.getAttribute('data-replace');
let codeHighlight = '';

switch (codeLanguage) {
case 'HTML':
case 'Astro':
codeHighlight = 'markup';
break;
case 'Markdown':
Expand All @@ -25,8 +27,45 @@ import { escapeHTML } from './util/functions';
codeHighlight = 'none';
}

const codeContainer = `<p class="border-top border-bottom py-2 px-3 mb-0">${codeLanguage}</p><pre class="border-0 my-0 code-static-toolbar"><code class="language-${codeHighlight} line-numbers">${escapeHTML(codeOriginal.innerHTML.trim())}</code></pre>`;
let codeEscaped = escapeHTML(codeOriginal.innerHTML.trim());
const start = '&lt;';
const startSlash = `${start}/`;
const end = '&gt;';
const endSlash = `/${end}`;
const contentQuotes = /content=&quot;([^&]*)&quot;/g;

codeOriginal.insertAdjacentHTML('afterend', codeContainer);
// Unfortunately, innerHTML interprets JSX like syntax incorrectly and we need to fix it here.
codeEscaped = codeEscaped
.replaceAll(`${start}callout`, `${start}Callout`)
.replaceAll(`${startSlash}callout`, `${startSlash}Callout`)
.replaceAll(`${start}collapsebutton`, `${start}CollapseButton`)
.replaceAll(`${startSlash}collapsebutton`, `${startSlash}CollapseButton`)
.replaceAll(`${start}iframe ratio`, `${start}Iframe ratio`)
.replaceAll(`${start}tabspanecontainer`, `${start}TabsPaneContainer`)
.replaceAll(`${startSlash}tabspanecontainer`, `${startSlash}TabsPaneContainer`)
.replaceAll(`${start}tabstabcontainer`, `${start}TabsTabContainer`)
.replaceAll(`${start}tabspane`, `${start}TabsPane`)
.replaceAll(`${start}xref`, `${start}Xref`)
.replaceAll(`value=&quot;example-define&quot;${end}`, `value=&quot;example-define&quot; ${endSlash}`)
.replaceAll(`anchor=&quot;why&quot;${end}`, `anchor=&quot;why&quot; ${endSlash}`)
.replaceAll(`${startSlash}tabspane`, `${startSlash}TabsPane`)
.replaceAll(`content=&quot;{tabs1}&quot;${end}`, `content=&quot;{tabs1}&quot; ${endSlash}`)
.replaceAll(`content=&quot;{tabs2}&quot;${end}`, `content=&quot;{tabs2}&quot; ${endSlash}`)
.replaceAll(`content=&quot;{tabs3}&quot;${end}`, `content=&quot;{tabs3}&quot; ${endSlash}`)
.replaceAll(`multi=&quot;version&quot;${end}`, `multi=&quot;version&quot; ${endSlash}`)
.replaceAll(`${startSlash}tabstabcontainer${end}`, '')
.replaceAll(`${startSlash}xref${end}`, '')
.replaceAll(`${startSlash}iframe${end}`, '')
.replace(contentQuotes, (match, p1) => `content=${p1}`);

if (codeReplace !== 'true') {
const codeContainer = `<p class="border-top border-bottom py-2 px-3 mb-0">${codeLanguage}</p><pre class="border-0 my-0 code-static-toolbar"><code class="language-${codeHighlight} line-numbers">${codeEscaped}</code></pre>`;

codeOriginal.insertAdjacentHTML('afterend', codeContainer);
} else {
const codeContainer = `<pre><code class="language-${codeHighlight} line-numbers">${codeEscaped}</code></pre>`;

codeOriginal.innerHTML = codeContainer;
}
});
})();
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
},
"dependencies": {
"@fortawesome/fontawesome-free": "^6.1.2",
"@playwright/test": "1.35.1",
"@playwright/test": "^1.44.0",
"@popperjs/core": "^2.11.8",
"@types/bootstrap": "^5.2.10",
"@types/luxon": "^3.3.0",
Expand Down
40 changes: 25 additions & 15 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1066,19 +1066,14 @@ __metadata:
languageName: node
linkType: hard

"@playwright/test@npm:1.35.1":
version: 1.35.1
resolution: "@playwright/test@npm:1.35.1"
"@playwright/test@npm:^1.44.0":
version: 1.44.0
resolution: "@playwright/test@npm:1.44.0"
dependencies:
"@types/node": "npm:*"
fsevents: "npm:2.3.2"
playwright-core: "npm:1.35.1"
dependenciesMeta:
fsevents:
optional: true
playwright: "npm:1.44.0"
bin:
playwright: cli.js
checksum: 10c0/5b28eece322645d05d2da286a2a023f99830df4ab8779ed15229c36fa0fdd7351fb2bc067446e0b1d8c719b60793658bad247308e3460c8dac9177d724a22dc3
checksum: 10c0/34c48b18f64f1be6ccba3e27fa4691aa9f7f8ea1eb1555ac4ae8e4bfc9136d61923a4376d8a711390c95401e4cfd77a15b18aab6a507bddd9925e6dab3acb9e1
languageName: node
linkType: hard

Expand Down Expand Up @@ -1917,7 +1912,7 @@ __metadata:
"@docsearch/css": "npm:^3.3.3"
"@docsearch/js": "npm:^3.3.3"
"@fortawesome/fontawesome-free": "npm:^6.1.2"
"@playwright/test": "npm:1.35.1"
"@playwright/test": "npm:^1.44.0"
"@popperjs/core": "npm:^2.11.8"
"@splidejs/splide": "npm:^4.1.4"
"@splidejs/splide-extension-auto-scroll": "npm:^0.5.3"
Expand Down Expand Up @@ -4862,12 +4857,27 @@ __metadata:
languageName: node
linkType: hard

"playwright-core@npm:1.35.1":
version: 1.35.1
resolution: "playwright-core@npm:1.35.1"
"playwright-core@npm:1.44.0":
version: 1.44.0
resolution: "playwright-core@npm:1.44.0"
bin:
playwright-core: cli.js
checksum: 10c0/378caaf452546554b01993006abf556fb2f35369355ff6cf462148ed154a177ff1cdcf7f90035c3e7cef3522435602fd4517f2f1a0a75eef92c4db4efdc24b02
checksum: 10c0/e1220371a76cdf145f6aaefb2dd6c5194531d1c1e2b67712c56dbc1d589dffb66fd4fc0168be60cd2115aca40660aa13c572e14be47674c0542bc879705b9fb3
languageName: node
linkType: hard

"playwright@npm:1.44.0":
version: 1.44.0
resolution: "playwright@npm:1.44.0"
dependencies:
fsevents: "npm:2.3.2"
playwright-core: "npm:1.44.0"
dependenciesMeta:
fsevents:
optional: true
bin:
playwright: cli.js
checksum: 10c0/dcbee9022623dd9e219e9867983789262e80339f0c3601219930883e5a304ce75e1397715c0f378a2bab0a799cf88a73ea4b58fe595cfd9058bd7a82f5d8e3b6
languageName: node
linkType: hard

Expand Down

0 comments on commit 35be37c

Please sign in to comment.