From 10edcf6a1777d7ad1568c96c3211619ed5a4b75b Mon Sep 17 00:00:00 2001 From: Pierre-Anthony Lemieux Date: Wed, 1 Jan 2025 11:23:00 -0800 Subject: [PATCH] Escape preview links https://github.com/SMPTE/html-pub/issues/299 --- scripts/build.mjs | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/scripts/build.mjs b/scripts/build.mjs index c04e70f..584bcc3 100644 --- a/scripts/build.mjs +++ b/scripts/build.mjs @@ -237,19 +237,19 @@ async function generatePubLinks(buildPaths, pubLinks) { if (pubLinks) { if ("clean" in pubLinks) - linksDocContents += `[Clean](${encodeURI(pubLinks.clean)})\n`; + linksDocContents += `[Clean](${pubLinks.clean})\n`; if ("pdf" in pubLinks) - linksDocContents += `[Clean PDF](${encodeURI(pubLinks.pdf)})\n`; + linksDocContents += `[Clean PDF](${pubLinks.pdf})\n`; if ("baseRedline" in pubLinks) - linksDocContents += `[Redline to current draft](${encodeURI(pubLinks.baseRedline)})\n`; + linksDocContents += `[Redline to current draft](${pubLinks.baseRedline})\n`; if ("pubRedline" in pubLinks) - linksDocContents += `[Redline to most recent edition](${encodeURI(pubLinks.pubRedline)})\n`; + linksDocContents += `[Redline to most recent edition](${pubLinks.pubRedline})\n`; if ("reviewZip" in pubLinks) - linksDocContents += `[ZIP package](${encodeURI(pubLinks.reviewZip)})\n`; + linksDocContents += `[ZIP package](${pubLinks.reviewZip})\n`; } else { linksDocContents += "No links available"; @@ -287,23 +287,23 @@ async function s3Upload(buildPaths, versionKey, generatedFiles) { } if ("pdf" in generatedFiles) { - pubLinks.pdf = `${deployPrefix}${s3PubKeyPrefix}${generatedFiles.pdf}`; + pubLinks.pdf = `${deployPrefix}${s3PubKeyPrefix}${encodeURIComponent(generatedFiles.pdf)}`; } if ("baseRedline" in generatedFiles) { - pubLinks.baseRedline = `${deployPrefix}${s3PubKeyPrefix}${generatedFiles.baseRedline}`; + pubLinks.baseRedline = `${deployPrefix}${s3PubKeyPrefix}${encodeURIComponent(generatedFiles.baseRedline)}`; } if ("pubRedline" in generatedFiles) { - pubLinks.pubRedline = `${deployPrefix}${s3PubKeyPrefix}${generatedFiles.pubRedline}`; + pubLinks.pubRedline = `${deployPrefix}${s3PubKeyPrefix}${encodeURIComponent(generatedFiles.pubRedline)}`; } if ("reviewZip" in generatedFiles) { - pubLinks.reviewZip = `${deployPrefix}${s3PubKeyPrefix}${generatedFiles.reviewZip}`; + pubLinks.reviewZip = `${deployPrefix}${s3PubKeyPrefix}${encodeURIComponent(generatedFiles.reviewZip)}`; } if ("libraryZip" in generatedFiles) { - pubLinks.libraryZip = `${deployPrefix}${s3PubKeyPrefix}${generatedFiles.libraryZip}`; + pubLinks.libraryZip = `${deployPrefix}${s3PubKeyPrefix}${encodeURIComponent(generatedFiles.libraryZip)}`; } s3SyncDir(buildPaths.pubDirPath, s3Client, s3Bucket, s3PubKeyPrefix); @@ -372,27 +372,27 @@ async function makePubArtifacts(buildPaths, generatedFiles, docMetadata) { let htmlLinks; if ("html" in generatedFiles) { - htmlLinks = `

Clean

\n`; + htmlLinks = `

Clean

\n`; } if ("pdf" in generatedFiles) { - htmlLinks += `

Clean PDF

\n`; + htmlLinks += `

Clean PDF

\n`; } if ("baseRedline" in generatedFiles) { - htmlLinks += `

Redline to current draft

\n`; + htmlLinks += `

Redline to current draft

\n`; } if ("pubRedline" in generatedFiles) { - htmlLinks += `

Redline to most recent edition

\n`; + htmlLinks += `

Redline to most recent edition

\n`; } if (generatedFiles.reviewZip !== undefined) { - htmlLinks += `

Review zip file

\n`; + htmlLinks += `

Review zip file

\n`; } if (generatedFiles.libraryZip !== undefined) { - htmlLinks += `

Library zip file

\n`; + htmlLinks += `

Library zip file

\n`; } fs.writeFileSync(buildPaths.pubArtifactsPath, `