Skip to content

fix: add JSON parse safety checks - I would be glad to become your contributor#5

Open
MatrixNeoKozak wants to merge 1 commit into
Yu9191:mainfrom
MatrixNeoKozak:fix/improvement-1780508644095
Open

fix: add JSON parse safety checks - I would be glad to become your contributor#5
MatrixNeoKozak wants to merge 1 commit into
Yu9191:mainfrom
MatrixNeoKozak:fix/improvement-1780508644095

Conversation

@MatrixNeoKozak
Copy link
Copy Markdown

This PR addresses potential runtime exceptions caused by unsafe JSON.parse() operations.

Changes

  • Added validation checks before accessing properties of parsed JSON objects in 1998.js and dtpk.js.
  • Wrapped the JSON.parse operations in safety checks to handle scenarios where the input body or nested data fields might be malformed or null/undefined.

Rationale

In the current implementation, JSON.parse(body) and nested property access (e.g., obj.data.mainInfoList) could throw exceptions if the API response unexpectedly returns invalid JSON, empty content, or unexpected structures. This can crash the script and cause it to fail silently.

Technical Impact

  • Increases the robustness and reliability of the scripts.
  • Prevents potential runtime errors that could stop the execution flow.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant