Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/visual-editor/src/a2/google-drive/unescape.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ const namedEntities: Record<string, string> = {
// add more as needed
};

/**
* WARNING: This function decodes HTML entities including `<`, `>`, and `&`.
* The output must NEVER be inserted into the DOM via innerHTML without
* sanitization. Use textContent or a sanitization library like DOMPurify.
*/
function unescape(html: string): string {
return html.replace(unescapeTest, (_, n) => {
n = n.toLowerCase();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ export function makeShareLinkFromTemplate({
}: MakeShareLinkFromTemplate): string {
const url = new URL(
urlTemplate
.replaceAll("{fileId}", fileId)
.replaceAll("{resourceKey}", resourceKey ?? "")
.replaceAll("{fileId}", encodeURIComponent(fileId))
.replaceAll("{resourceKey}", resourceKey ? encodeURIComponent(resourceKey) : "")
);
// Remove any empty parameters. A slightly hacky way to clean up resourceKey
// parameters when there is no resourceKey.
Expand Down