Read remaining config files as UTF-8 regardless of locale#4134
Open
lunkwill42 wants to merge 3 commits into
Open
Read remaining config files as UTF-8 regardless of locale#4134lunkwill42 wants to merge 3 commits into
lunkwill42 wants to merge 3 commits into
Conversation
Several subsystems read config files with a plain configparser.ConfigParser (or a bare open()) and did not specify an encoding, so the file was decoded using the locale's preferred encoding. Under a non-UTF-8 locale (e.g. LANG=C) that raises UnicodeDecodeError on any config file containing UTF-8 -- the same class of bug reported in #4132 for ipdevpoll.conf. Read these files as UTF-8 too, matching what open_configfile() already does. Refs #4132
Add a new test module covering NAV's config file handling: that every shipped file under etc/ is valid UTF-8, that the shipped INI and TOML examples parse through NAV's own readers, and that a configparser-based reader decodes as UTF-8 even when the locale's preferred encoding is ASCII (a regression test for the raw-reader fix). Refs #4132
|
|
❌ The last analysis has failed. |
Test results 5 files 5 suites 8m 6s ⏱️ Results for commit dd06276. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #4134 +/- ##
=======================================
Coverage 65.37% 65.37%
=======================================
Files 629 629
Lines 47206 47206
=======================================
Hits 30861 30861
Misses 16345 16345 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.



Scope and purpose
Follow-up to #4132, which #4133 fixed for
ipdevpoll.confon the5.19.xbranch. That crash — aUnicodeDecodeErrorraised when a config file containing UTF-8 is read under a non-UTF-8 locale such asLANG=C— was never unique to ipdevpoll: several other readers decode config files using the locale's preferred encoding rather than UTF-8, so the same failure can strike any of them. This hardens the remaining readers (arnold,logengine,logs,mailin, and the syslogger web view — plusarnold.parse_nonblock_file, which reads its file with a bareopen()) to always decode as UTF-8, matching whatopen_configfile()already does.It also adds a test module that walks the shipped
etc/tree asserting every example file is valid UTF-8 and that the INI and TOML examples parse through NAV's own readers, plus a locale-forced regression test proving a configparser-based reader still decodes UTF-8 when the interpreter's preferred encoding is ASCII.The
NAVConfigParserfix and the shipped-config character revert from #4133 reachmastervia the normal5.19.xmerge-forward and are intentionally not duplicated here.Contributor Checklist
Every pull request should have this checklist filled out, no matter how small it is.
More information about contributing to NAV can be found in the
Hacker's guide to NAV.
Added/changed documentationmaster, as this hardens latent behaviour present across all versions rather than fixing the specific 5.19 regression (Read config files as UTF-8 regardless of locale #4133 handles that on5.19.x).If applicable: Created new issues if this PR does not fix the issue completely/there is further work to be doneIf it's not obvious from a linked issue, described how to interact with NAV in order for a reviewer to observe the effects of this change first-hand (commands, URLs, UI interactions)If this results in changes in the UI: Added screenshots of the before and after