Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Escape filenames in URLs #565

Merged
merged 1 commit into from
Dec 10, 2024
Merged
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
2 changes: 1 addition & 1 deletion src/lib/common/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export function getEditUrl(
filename: string,
schema: Schema,
): string {
return `scheme.html?authority=${authority}&schema=${schema}&file=${filename}`;
return `scheme.html?authority=${authority}&schema=${schema}&file=${encodeURIComponent(filename)}`;
}

// Returns a list of filenames and the detected schema
Expand Down
4 changes: 2 additions & 2 deletions src/pages/SketchSchemes.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@
let params = new URLSearchParams(window.location.search);
// If the authority is invalid, it'll be handled in onMount asynchronously
let authority = params.get("authority") || "";
let filename = params.get("file") || "";
let filename = decodeURIComponent(params.get("file") || "");

if (window.localStorage.getItem(getKey(authority, filename)) == null) {
// If either the filename or authority is wrong, redirect to the very first
// page. This might be annoying if the authority is correct, but it's
// simpler. Unless a user copies a bad URL, this shouldn't happen anyway
window.location.href = `choose_area.html?schema=${$schema}&error=File ${filename} in authority ${authority} not found`;
window.location.href = `choose_area.html?schema=${$schema}&error=File ${encodeURIComponent(filename)} in authority ${authority} not found`;
}

mapStyle.set(params.get("style") || "streets");
Expand Down
Loading