Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

Fix `+` character in file paths being decoded as space in URLs (#8344)

Akshay Agrawalc1fde07d6501
diff --git a/frontend/src/components/pages/home-page.tsx b/frontend/src/components/pages/home-page.tsx
index 77ee611763..c7ef9cbce4 100644
--- a/frontend/src/components/pages/home-page.tsx
+++ b/frontend/src/components/pages/home-page.tsx
@@ -326,7 +326,7 @@ const Node = ({ node, style }: NodeRendererProps<FileInfo>) => {
return (
<a
className={itemClassName}
- href={asURL(`?file=${relativePath}`).toString()}
+ href={asURL(`?file=${encodeURIComponent(relativePath)}`).toString()}
target={tabTarget(relativePath)}
>
{iconEl}
@@ -401,8 +401,10 @@ const MarimoFileComponent = ({ file }: { file: MarimoFile }) => {
// We want to keep the sessionId in this case
const isNewNotebook = isSessionId(file.path);
const href = isNewNotebook
- ? asURL(`?file=${file.initializationId}&session_id=${file.path}`)
- : asURL(`?file=${file.path}`);
+ ? asURL(
+ `?file=${encodeURIComponent(file.initializationId ?? file.path)}&session_id=${file.path}`,
+ )
+ : asURL(`?file=${encodeURIComponent(file.path)}`);
const isMarkdown = file.path.endsWith(".md");
diff --git a/frontend/src/utils/links.ts b/frontend/src/utils/links.ts
index 2eedace452..8170f68576 100644
--- a/frontend/src/utils/links.ts
+++ b/frontend/src/utils/links.ts
@@ -7,5 +7,5 @@ import { asURL } from "./url";
*/
export function openNotebook(path: string) {
// There is no leading `/` in the path in order to work when marimo is at a subpath.
- window.open(asURL(`?file=${path}`).toString(), "_blank");
+ window.open(asURL(`?file=${encodeURIComponent(path)}`).toString(), "_blank");
}
diff --git a/frontend/src/utils/urls.ts b/frontend/src/utils/urls.ts
index 0891521621..f206632647 100644
--- a/frontend/src/utils/urls.ts
+++ b/frontend/src/utils/urls.ts
@@ -24,7 +24,7 @@ export function hasQueryParam(key: string, value?: string): boolean {
export function newNotebookURL() {
const sessionId = generateSessionId();
const initializationId = `__new__${sessionId}`;
- return asURL(`?file=${initializationId}`).toString();
+ return asURL(`?file=${encodeURIComponent(initializationId)}`).toString();
}
const urlRegex = /^(https?:\/\/\S+)$/;