Closed Norlock closed 4 months ago
Thanks for this PR. I was unfamiliar with the requirement to url encode pattern strings, and I wasn't able to find a reference to that in the json schema docs. I tried this JSON schema validator https://www.jsonschemavalidator.net/ and it didn't seem to do the url decoding (it worked as expected with the pattern "^[0-9A-Za-z\\\\-]*$"
). Can you share your rationale for this change? Thanks!
You are right I got this from a stack overflow post and thought it was a correct way to escape but I assumed it a bit too quickly, :/ I will close it
Thanks for checking. And we appreciate the effort nonetheless!
Problem
If you pass a JSON schema with a regex pattern, you will need to encode it to avoid certain characters (e.g. backslash) to escape the JSON string.
An incorrect unescaped JSON string:
vs a correct escaped JSON string:
Solution
This PR makes sure it will decode the string value of the pattern field first before trying to validate if the regex is correct.