Repository navigation
fix: initialize form serialization before appending fields - #546
Open
xunguangzlj-cloud wants to merge 1 commit into
Open
xunguangzlj-cloud wants to merge 1 commit into
xunguangzlj-cloud wants to merge 1 commit into
Conversation
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
Initialize
base.stringifywith an empty string before appending form fields. The Baidu authorization POST ingetToken()uses this helper: its firstgrant_permissions_arrfield was encoded asundefinedgrant_permissions_arr, becausestrstarted asundefined. An empty form (or one containing only empty arrays) also threw when callingstr.slice().The production fix is one line. Existing URI encoding, repeated array fields, field order and exclusion of inherited properties remain unchanged.
Validation
node --test tests/stringify.test.cjs: 9 passed. The tests extract and execute the actual method from the distributed userscript; no copy of the algorithm is maintained.LINKSWIFT_SOURCEat unchangeddev(c62d10a3071b089c6ffef4e9fa56f05bbb03079c) makes the same 9 tests fail.npx --no-install eslint .: 0 errors, retaining the existing two unused-variable warnings (items,token).node --checkon the main userscript andgit diff --check: passed.npm testis currently the repository's fixed failing placeholder (Error: no test specified); this PR leaves that unrelated script unchanged and uses the explicit Node test command above. Tests use no credentials or network access. A live Baidu account/authorization session has not been exercised, so this verifies the request-body encoding rather than claiming end-to-end OAuth success.Targets
devas required by the contribution guide. No userscript version or dependency changes. Prepared with AI assistance under the account owner's direction.