Summary
Loading a local file through the internal pseudo-URL http://localfile.internal?path=<base64url(path)> (produced by URLUtils.pathToLocalURL) breaks when -ignoreQuery (i.e. LoadOptions.ignoreUrlQuery) is set.
Root cause
URLUtils.pathToLocalURL encodes the file path in the query parameter path: http://localfile.internal?path=<base64>.
CombinedUrlNormalizer ends with URLUtils.normalizeOrNull(normURL, options.ignoreUrlQuery), and URLUtils.normalize(url, ignoreUrlQuery=true) removes the whole query via URIBuilder.removeQuery().
- The driver's local-file branch still fires (
isLocalFile only checks the http://localfile.internal prefix), but PulsarWebDriver.openLocalFile -> URLUtils.localURLToPath then throws IllegalArgumentException: Missing query parameter 'path' in local file url: http://localfile.internal.
Repro (expected)
val url = URLUtils.pathToLocalURL(path)
session.load(url, "-refresh -ignoreQuery") // throws / fails to load
Suggested fixes (pick one)
- Preserve the
path parameter for localfile.internal URLs during normalization even when ignoreUrlQuery is set.
- Move the base64-encoded path from the query into the URL path segment (
http://localfile.internal/<base64>), making it immune to query stripping. This changes URLUtils.pathToLocalURL/localURLToPath in the upstream pulsar-common dependency.
- If neither is feasible, at least document the conflict and validate in
normalize so the error is clear.
References
pathToLocalURL/localURLToPath: pulsar-common dependency (ai.platon.pulsar.common.urls.URLUtils)
CombinedUrlNormalizer: browser4-core/browser4-skeleton/src/main/kotlin/ai/platon/pulsar/skeleton/common/urls/CombinedUrlNormalizer.kt
- Driver local-file branch:
pulsar-browser dependency (PulsarWebDriver.openLocalFile)
- Existing usage test:
browser4-tests/pulsar-it-tests/src/test/kotlin/ai/platon/pulsar/basic/session/PulsarSessionTests.kt
Summary
Loading a local file through the internal pseudo-URL
http://localfile.internal?path=<base64url(path)>(produced byURLUtils.pathToLocalURL) breaks when-ignoreQuery(i.e.LoadOptions.ignoreUrlQuery) is set.Root cause
URLUtils.pathToLocalURLencodes the file path in the query parameterpath:http://localfile.internal?path=<base64>.CombinedUrlNormalizerends withURLUtils.normalizeOrNull(normURL, options.ignoreUrlQuery), andURLUtils.normalize(url, ignoreUrlQuery=true)removes the whole query viaURIBuilder.removeQuery().isLocalFileonly checks thehttp://localfile.internalprefix), butPulsarWebDriver.openLocalFile->URLUtils.localURLToPaththen throwsIllegalArgumentException: Missing query parameter 'path' in local file url: http://localfile.internal.Repro (expected)
Suggested fixes (pick one)
pathparameter forlocalfile.internalURLs during normalization even whenignoreUrlQueryis set.http://localfile.internal/<base64>), making it immune to query stripping. This changesURLUtils.pathToLocalURL/localURLToPathin the upstreampulsar-commondependency.normalizeso the error is clear.References
pathToLocalURL/localURLToPath:pulsar-commondependency (ai.platon.pulsar.common.urls.URLUtils)CombinedUrlNormalizer:browser4-core/browser4-skeleton/src/main/kotlin/ai/platon/pulsar/skeleton/common/urls/CombinedUrlNormalizer.ktpulsar-browserdependency (PulsarWebDriver.openLocalFile)browser4-tests/pulsar-it-tests/src/test/kotlin/ai/platon/pulsar/basic/session/PulsarSessionTests.kt