fix(config_file): refuse breaklines in config dict#169
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR hardens LanguageTool local server config serialization by rejecting CR/LF characters that could escape the generated one-option-per-line config file format.
Changes:
- Adds a helper to reject
\nand\rin config keys and encoded values. - Applies the validation across language-specific options, path options, and schema-backed options.
- Adds parametrized tests for newline injection attempts in keys, scalar values, and list values.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
language_tool_python/config_file.py |
Adds CR/LF validation during config encoding before temporary config file creation. |
tests/test_config.py |
Adds regression coverage for line-break injection in config serialization. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
51bdf34 to
b70d708
Compare
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.
fix(config_file): refuse breaklines in config dict
Why the pull request was made
To avoid that, if a part of the config come from an untrusted source, a config value could break a line and insert other config params.
Summary of changes
Screenshots (if appropriate):
Not applicable.
How has this been tested?
Applied local tests (inlcuding new ones about our issue).
Resources
Not applicable.
Types of changes
Checklist