mirror of
https://github.com/apple/pkl.git
synced 2026-01-11 22:30:54 +01:00
Fix parsing of URLs with plus signs (#1335)
This fixes an issue where URLs with schemes that contain `+`, `-`, and `.` would not be parsed correctly. For example, `foo+bar:///?baz.pkl` would turn into `foo+bar:///%3Fbaz.pkl`. The query param is lost, and turned into the path.
This commit is contained in:
@@ -48,7 +48,7 @@ import org.pkl.core.runtime.VmExceptionBuilder;
|
|||||||
public final class IoUtils {
|
public final class IoUtils {
|
||||||
|
|
||||||
// Don't match paths like `C:\`, which are drive letters on Windows.
|
// Don't match paths like `C:\`, which are drive letters on Windows.
|
||||||
private static final Pattern uriLike = Pattern.compile("\\w+:[^\\\\].*");
|
private static final Pattern uriLike = Pattern.compile("[\\w+.-]+:[^\\\\].*");
|
||||||
|
|
||||||
private static final Pattern windowsPathLike = Pattern.compile("\\w:\\\\.*");
|
private static final Pattern windowsPathLike = Pattern.compile("\\w:\\\\.*");
|
||||||
|
|
||||||
|
|||||||
@@ -52,4 +52,10 @@ examples {
|
|||||||
|
|
||||||
new Resource { base64 = "AQIDBA==" }.bytes
|
new Resource { base64 = "AQIDBA==" }.bytes
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// test parsing of URIs.
|
||||||
|
// see https://github.com/apple/pkl/pull/1335
|
||||||
|
["absolute URI scheme with plus"] {
|
||||||
|
module.catch(() -> read("foo+bar///?baz=buz"))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,4 +36,7 @@ examples {
|
|||||||
"AQIDBA=="
|
"AQIDBA=="
|
||||||
Bytes(1, 2, 3, 4)
|
Bytes(1, 2, 3, 4)
|
||||||
}
|
}
|
||||||
|
["absolute URI scheme with plus"] {
|
||||||
|
"Cannot find resource `foo+bar///?baz=buz`."
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user