Skip to content

JSON Parser Bug Fix#2242

Open
Adityakk9031 wants to merge 2 commits intojson-schema-org:mainfrom
Adityakk9031:#2237
Open

JSON Parser Bug Fix#2242
Adityakk9031 wants to merge 2 commits intojson-schema-org:mainfrom
Adityakk9031:#2237

Conversation

@Adityakk9031
Copy link
Copy Markdown
Contributor

@Adityakk9031 Adityakk9031 commented Feb 16, 2026

What kind of change does this PR introduce?

Bug fix – corrects string detection in the custom JSON parser to properly handle escaped backslashes and quotes.

Issue Number

Closes #2237

Screenshots / Videos

N/A – this is a logic fix in the parser. Automated tests have been added to verify the behavior.

Summary

This PR fixes a bug in the custom JSON parser (lib/getPartsOfJson.ts) where strings ending with an escaped backslash (for example, "value \\\\") were incorrectly treated as unterminated. This caused syntax highlighting and parsing issues for the remainder of the JSON block. The fix updates the string‑matching and quote‑detection logic so that escaped characters are handled correctly and valid JSON strings are no longer misclassified.

Changes

  • Updated regexString to correctly match strings containing escaped characters as produced by JSON.stringify.
  • Updated regexDoubleQuote to use a parity‑aware lookbehind so that only truly unescaped quotes are treated as string terminators.
  • Ensured that non‑capturing groups are used in the lookbehind to remain compatible with the getFindResultsByGlobalRegExp helper.

Does this PR introduce a breaking change?

No.

Checklist

Please ensure the following tasks are completed before submitting this pull request.

@github-actions
Copy link
Copy Markdown

Hi @Adityakk9031! Thanks a lot for your contribution!

I noticed that the following required information is missing or incomplete: kind of change description, completed checklist items

Please update the PR description to include this information. You can find placeholders in the PR template for these items.

Thanks a lot!

@github-actions
Copy link
Copy Markdown

github-actions bot commented Feb 16, 2026

built with Refined Cloudflare Pages Action

⚡ Cloudflare Pages Deployment

Name Status Preview Last Commit
website ✅ Ready (View Log) Visit Preview a69042b

@Adityakk9031
Copy link
Copy Markdown
Contributor Author

@Utkarsh-123github sir please check this pr

@codecov
Copy link
Copy Markdown

codecov bot commented Feb 16, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (1e8d74b) to head (a69042b).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #2242   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           30        30           
  Lines          663       663           
  Branches       205       205           
=========================================
  Hits           663       663           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Adityakk9031
Copy link
Copy Markdown
Contributor Author

@jagpreetrahi sir have a look

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Ready to review

Development

Successfully merging this pull request may close these issues.

🐛 Bug: JSON parsing bug: Incorrect handling of backslash-escaped quotes

1 participant