Skip to content

Fix resolution of percent-encoded schema paths in modelines - #1316

Merged
datho7561 merged 2 commits into
redhat-developer:mainfrom
shin19991207:fix-encoded-modeline
Aug 6, 2026
Merged

Fix resolution of percent-encoded schema paths in modelines#1316
datho7561 merged 2 commits into
redhat-developer:mainfrom
shin19991207:fix-encoded-modeline

Conversation

@shin19991207

Copy link
Copy Markdown
Member

What does this PR do?

Prevents percent-encoded schema paths in modelines from being encoded a second time when converted to file URIs.

For example, this following percent-encoded modeline should resolve to a schema named encoded:schema.json:

# yaml-language-server: $schema=./encoded%3Aschema.json

Previously, the existing percent escape was encoded again:

./encoded%3Aschema.json
        ↓
file:///.../encoded%253Aschema.json

Consequently, the schema request targeted a file literally named encoded%3Aschema.json instead of decoding %3A to :.

What issues does this PR fix or reference?

Related to redhat-developer/vscode-yaml#1274
This is a separate modeline path case discovered while investigating encoded schema URIs in yaml.schemas.

Is it tested? How?

  • New automated tests
  • Tested manually:
    1. Created a schema named encoded:schema.json (For Windows, use encoded schema.json because : is invalid in filenames on Windows)
    2. Create a yaml file with a percent-encoded modeline that points to the file # yaml-language-server: $schema=./encoded%3Aschema.json (or # yaml-language-server: $schema=./encoded%20schema.json for Windows)
    3. Expect the yaml to resolve against the schema correctly

Signed-off-by: Morgan Chang <shin19991207@gmail.com>
Signed-off-by: Morgan Chang <shin19991207@gmail.com>
@shin19991207
shin19991207 force-pushed the fix-encoded-modeline branch from ec34c15 to 9174b21 Compare August 6, 2026 00:04
@datho7561

Copy link
Copy Markdown
Contributor

Tried this out on Linux and it was working well; I'll also check it on Windows before approving...

@datho7561

Copy link
Copy Markdown
Contributor

Works on Windows too!

@datho7561 datho7561 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, Morgan!

@datho7561
datho7561 merged commit d399eb9 into redhat-developer:main Aug 6, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants