Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

fix(web): escape signed URLs in DASH manifest attributes

Richie McIlroyedab77be2741
diff --git a/apps/web/lib/video-convert.ts b/apps/web/lib/video-convert.ts
index efa43ae66..6a842cfc3 100644
--- a/apps/web/lib/video-convert.ts
+++ b/apps/web/lib/video-convert.ts
@@ -66,6 +66,23 @@ function resolveResourceUrl(
return withQuery(new URL(resource, baseUrl).toString(), query);
}
+function escapeXmlAttribute(value: string): string {
+ return value.replace(/[&<>"']/g, (char) => {
+ switch (char) {
+ case "&":
+ return "&amp;";
+ case "<":
+ return "&lt;";
+ case ">":
+ return "&gt;";
+ case '"':
+ return "&quot;";
+ default:
+ return "&apos;";
+ }
+ });
+}
+
async function materializeHlsPlaylist(
playlistUrl: string,
dirPath: string,
@@ -162,7 +179,7 @@ async function materializeMpdManifest(
/(initialization|media)="([^"]+)"/g,
(_, attribute: string, resource: string) => {
const resolved = resolveResourceUrl(resource, baseUrl, query);
- return `${attribute}="${resolved}"`;
+ return `${attribute}="${escapeXmlAttribute(resolved)}"`;
},
);