ADR: Handling quotes around values #95
lipkau
announced in
Architectural Decision Records
Replies: 1 comment 2 replies
-
|
Hi @lipkau! First of all, thank you for your work! You're great!
|
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
PR#42 was merged and released in v3.0 as a breaking change, as it changed the behaviour of the parsing of the value.
The PR introduced the interpretations of quotation marks (
['"]) aroundvalues.It turns out, that this behaviour is controversial, as seen in issues #50, #49 and PR#77.
Summary
This Architectural Decision Record analyses the handling of quotation marks (
['"]) around values in INI files of this module.It documents the history and the desired behaviour.
The research conducted shows that handling of quotes varies significantly across languages and libraries:
Given the lack of a universal INI specification and the inconsistencies across implementations,
the decision has been made to not support the interpretation or stripping of quotation marks.
Instead:
./Examplesdirectory.This approach prioritizes simplicity and user control, avoiding unnecessary complexity while aligning with PowerShell's flexibility.
Behavioural examples
before #42
after #42
Observations
Spec
The INI specification is poorly defined—there isn’t a universal standard.
Each implementation handles things differently, leading to inconsistencies.
How do others do it
The table below summarizes how various languages and libraries handle quotes around values in INI files:
GetPrivateProfileStringconfigparserininpm packageConfig::IniFilesiniparseparse_ini_filegopkg.in/ini.v1ini.hResearch is documented in Appendix A
Legend
Argumentation
The handling of quotes is inconsistent across different languages and libraries (as seen in Observations);
some strip quotes, while others preserve them.
Additionally, most implementations focus on reading and parsing INI files to load configurations into memory,
rather than manipulating the files themselves, as is our case.
Stripping quotation marks make the creation of a INI file unreasonably complex.
Decision
Although this module offers a lot of flexibility, it never be able to please everyone.
I have decided to not support the interpretation/stripping of quotation marks.
Powershell make it simple enough for the user to manipulate the value.
There shall be an example for adding and removing quotes in the
./Examplesdirectory.Appendix A: Testing other languages
The findings in this chapter use the following INI file as input:
Windows API
GetPrivateProfileStringFinding: quotes are stripped.
Python:
configparserFinding: quotes are untouched.
Code
Node (js):
ininpm packageFinding: quotes are stripped.
Code
Perl:
Config::IniFilesFinding: quotes are untouched.
Code
Ruby:
iniparseFinding: quotes are untouched.
Code
PHP:
parse_ini_fileFinding: quotes are stripped.
Code
Go:
gopkg.in/ini.v1Finding: quotes are stripped.
Code
C++:
ini.hFinding: quotes are untouched.
Code
Beta Was this translation helpful? Give feedback.
All reactions