fix: path should be URL-encoded in Elixir code (#2926)

Signed-off-by: Cocoa <i@uwucocoa.moe>
Co-authored-by: Wojtek Mach <wojtekmach@users.noreply.github.com>
This commit is contained in:
Cocoa 2025-02-12 16:10:24 +01:00 committed by GitHub
parent 61bce0f39b
commit 465d711395
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 8 additions and 3 deletions

View file

@ -110,7 +110,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
}
for url in urls {
ElixirKit.API.publish("open", url.absoluteString)
ElixirKit.API.publish("open", "file://\(url.path)")
}
}

View file

@ -18,8 +18,7 @@ static class LivebookMain
if (args.Length == 1 && args[0].StartsWith(prefix))
{
var uri = new System.Uri(args[0].Remove(0, prefix.Length));
url = uri.AbsoluteUri;
url = $"file://{args[0].Remove(0, prefix.Length)}";
}
var logPath = getLogPath();

View file

@ -21,6 +21,12 @@ defmodule Livebook.UtilsTest do
assert Livebook.Utils.expand_desktop_url("file://c\\foo.txt") ==
"http://localhost:4002/open?path=c%5Cfoo.txt"
assert Livebook.Utils.expand_desktop_url("file:///this is a dir/with many spaces/foo.txt") ==
"http://localhost:4002/open?path=%2Fthis+is+a+dir%2Fwith+many+spaces%2Ffoo.txt"
assert Livebook.Utils.expand_desktop_url("file://\\\\127.0.0.1\\my folder\\foo.txt") ==
"http://localhost:4002/open?path=%5C%5C127.0.0.1%5Cmy+folder%5Cfoo.txt"
end
test "livebook://" do