fix: validate NEWAPI token input across UI and API#109
Merged
cnlimiter merged 4 commits intocnlimiter:masterfrom Mar 27, 2026
Merged
fix: validate NEWAPI token input across UI and API#109cnlimiter merged 4 commits intocnlimiter:masterfrom
cnlimiter merged 4 commits intocnlimiter:masterfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves NEWAPI token validation across the Web UI and API, and hardens the NEWAPI upload flow to avoid leaking token-bearing request data.
Changes:
- Add UI-side validation for NEWAPI “Root Token / API Key” input and show a hint in settings.
- Add API-side validation for NEWAPI service create/update routes using shared normalization logic.
- Update NEWAPI upload request construction (ASCII-safe JSON payload + explicit UTF-8 encoding) and add tests for validation behavior.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_settings_newapi_validation.cjs | Adds Node-based unit tests for the new UI validation function in settings.js. |
| tests/test_newapi_upload.py | Adds tests for ASCII-only authorization token enforcement and upload request shape. |
| tests/test_newapi_service_routes.py | Adds tests ensuring API routes reject non-ASCII NEWAPI tokens on create/update. |
| templates/settings.html | Adds a user-facing hint that the token must be ASCII-only. |
| static/js/settings.js | Introduces validateNewapiApiKeyInput() and uses it when saving NEWAPI services in the UI. |
| src/web/routes/upload/newapi_services.py | Normalizes/validates NEWAPI API key on create/update and returns 400 on invalid tokens. |
| src/core/upload/newapi_upload.py | Adds shared token normalization, adjusts JSON encoding, and changes request sending/logging behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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
Validation