Repository navigation
fix(python): reject non-standard JSON constants in request post data - #3376
Closed
himanshug189-sketch wants to merge 1 commit into
Closed
himanshug189-sketch wants to merge 1 commit into
himanshug189-sketch wants to merge 1 commit into
Conversation
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes an issue in
Request.post_data_jsonwhere Python's JSON parser accepts non-standard JSON constants (NaN,Infinity, and-Infinity) instead of rejecting them.The behavior is inconsistent with JavaScript's
JSON.parse(), which rejects these values as invalid JSON.Problem
Python's built-in
json.loads()accepts the following non-standard JSON constants by default:NaNInfinity-InfinityAs a result, accessing
Request.post_data_jsoncould return Python floating-point values (nan,inf, and-inf) instead of raising an error for invalid JSON input.Changes Made
parse_constanthandler to reject non-standard JSON constants.Errorwith the existing error message.NaN,Infinity, and-Infinity.Test Coverage
Added a regression test covering all three non-standard JSON constants.
Validation performed:
tests/async/python/test_network.py— 18 tests passed.git diff --checkpassed.Expected Behavior
Request.post_data_jsonshould reject non-standard JSON constants and raise a PlaywrightError, consistent with JavaScript JSON parsing behavior.Related Issue
Related to #3375.
Note: Submitted as a Draft PR for maintainer feedback and review.