From 33b5b5b3121a5a2ef67f00a76b3774a88a0dd7e4 Mon Sep 17 00:00:00 2001 From: Paul Kulchenko Date: Wed, 31 Aug 2022 22:14:06 -0700 Subject: [PATCH] Remove path escaping from LaunchBrowser (#584) This is so you can have `?query=args`. --- tool/net/help.txt | 4 +++- tool/net/redbean.c | 3 +-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/tool/net/help.txt b/tool/net/help.txt index a0b7bdb1b..0d3018007 100644 --- a/tool/net/help.txt +++ b/tool/net/help.txt @@ -672,7 +672,9 @@ FUNCTIONS LaunchBrowser([path:str]) Launches web browser on local machine with URL to this redbean - server. This function may be called from your /.init.lua. + server. It is the responsibility of the caller to escape the path + with EscapePath if needed, as it's not escaped automatically. + This function may be called from /.init.lua. CategorizeIp(ip:uint32) → str Returns a string describing an IP address. This is currently Class diff --git a/tool/net/redbean.c b/tool/net/redbean.c index 567471a0f..344282886 100644 --- a/tool/net/redbean.c +++ b/tool/net/redbean.c @@ -2767,8 +2767,7 @@ static void LaunchBrowser(const char *path) { if (*path != '/') path = gc(xasprintf("/%s", path)); if ((prog = commandv(GetSystemUrlLauncherCommand(), gc(malloc(PATH_MAX)), PATH_MAX))) { - u = gc(xasprintf("http://%s:%d%s", inet_ntoa(addr), port, - gc(EscapePath(path, -1, 0)))); + u = gc(xasprintf("http://%s:%d%s", inet_ntoa(addr), port, path)); DEBUGF("(srvr) opening browser with command %`'s %s", prog, u); ignore.sa_flags = 0; ignore.sa_handler = SIG_IGN;