Skip to content

bug: -ignoreQuery breaks local file loading via localfile.internal pseudo-URL #574

Description

@platonai

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)

  1. Preserve the path parameter for localfile.internal URLs during normalization even when ignoreUrlQuery is set.
  2. 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.
  3. 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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions