Skip to content

Fixes microsoft/vscode#240654: Avoid encoding reserved chars in JSON schema URL #244934

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

pedrofrazaopacheco
Copy link
Contributor

@pedrofrazaopacheco pedrofrazaopacheco commented Mar 27, 2025

Fixes #240654

Title: Prevent percent‑encoding of query parameters when building JSON schema URI

Description:
This change uses skipEncoding in uri.toString(true) to avoid percent‑encoding characters such as :, &, and = when constructing the schema URL. By preserving these characters, the generated URI remains valid and the JSON schema can be successfully retrieved.

Verification:
I deployed a test endpoint at https://vscode-json-bug.vercel.app/ and confirmed that the schema file is reachable only after applying this change.

Reproduction steps:

  1. Add the following to your settings.json:
    "json.schemas": [
      {
        "fileMatch": ["associations.config*.json"],
        "url": "https://vscode-json-bug.vercel.app/api/my-file?cmd=readdoc1&downloadid=(9CF9004A-DC3C-746A-97F5-7960CF3BDE0D)&fname=associations.config.schema.json"
      }
    ]
  2. Create associations.config.json with {} as its content.
  3. Open the Problems panel — there should be no errors loading the schema URL.

Before this change:
Loading failed with:

Unable to load schema from ‘…’: Not Found. The requested location could not be found.

After this change:
The schema URL is valid and loads successfully.

Use skipEncoding in uri.toString(true) to prevent percent‑encoding of
characters like ":", "&" and "=" when building the URI.
This ensures the JSON schema URL remains valid.
@pedrofrazaopacheco pedrofrazaopacheco changed the title Fix #240654: Avoid encoding reserved chars in JSON schema URL Fixes microsoft/vscode#240654: Avoid encoding reserved chars in JSON schema URL Mar 27, 2025
@aeschli aeschli added this to the April 2025 milestone Mar 28, 2025
@aeschli
Copy link
Contributor

aeschli commented Mar 28, 2025

Thanks @pedrofrazaopacheco that's a good fix!

@pedrofrazaopacheco
Copy link
Contributor Author

Hey @aeschli! Hope all is well. Just wondering if you need anything from my end to merge PR#240654. Thanks and have a great day!

@aeschli aeschli merged commit 389c5dd into microsoft:main Apr 16, 2025
7 checks passed
@vs-code-engineering vs-code-engineering bot locked and limited conversation to collaborators May 31, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[json] Wrong encoding of JSON schema URL
4 participants