-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enh(toml)(ini) Improve parsing of complex keys (#2595)
Fixes: #2594
- Loading branch information
Showing
4 changed files
with
80 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<span class="hljs-comment"># Bare keys:</span> | ||
<span class="hljs-attr">key</span> = <span class="hljs-string">"value"</span> | ||
<span class="hljs-attr">bare_key</span> = <span class="hljs-string">"value"</span> | ||
<span class="hljs-attr">bare-key</span> = <span class="hljs-string">"value"</span> | ||
<span class="hljs-attr">1234</span> = <span class="hljs-string">"value"</span> | ||
|
||
<span class="hljs-comment"># Quoted keys:</span> | ||
<span class="hljs-attr">"127.0.0.1"</span> = <span class="hljs-string">"value"</span> | ||
<span class="hljs-attr">"character encoding"</span> = <span class="hljs-string">"value"</span> | ||
<span class="hljs-attr">"ʎǝʞ"</span> = <span class="hljs-string">"value"</span> | ||
<span class="hljs-attr">'key2'</span> = <span class="hljs-string">"value"</span> | ||
<span class="hljs-attr">'quoted "value"'</span> = <span class="hljs-string">"value"</span> | ||
|
||
<span class="hljs-attr">"key \"containing\" backslash"</span> = <span class="hljs-number">6</span> | ||
<span class="hljs-attr">'key \"containing" backslash\'</span> = <span class="hljs-number">6</span> | ||
|
||
<span class="hljs-comment"># empty quoted key is allowed</span> | ||
<span class="hljs-attr">""</span> = <span class="hljs-string">"blank"</span> <span class="hljs-comment"># VALID but discouraged</span> | ||
<span class="hljs-attr">''</span> = <span class="hljs-string">'blank'</span> <span class="hljs-comment"># VALID but discouraged</span> | ||
|
||
<span class="hljs-comment"># Dotted keys:</span> | ||
<span class="hljs-attr">name</span> = <span class="hljs-string">"Orange"</span> | ||
<span class="hljs-attr">physical.color</span> = <span class="hljs-string">"orange"</span> | ||
<span class="hljs-attr">physical.shape</span> = <span class="hljs-string">"round"</span> | ||
<span class="hljs-attr">site."google.com"</span> = <span class="hljs-literal">true</span> | ||
<span class="hljs-attr">3.14159</span> = <span class="hljs-string">"pi"</span> | ||
|
||
<span class="hljs-comment"># Whitespace around dot-separated parts is ignored:</span> | ||
<span class="hljs-attr">hello . world</span> = <span class="hljs-string">"!"</span> | ||
|
||
<span class="hljs-comment"># Whitespace is ignored around key names and values</span> | ||
<span class="hljs-attr">hello</span> = <span class="hljs-string">"World!"</span> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Bare keys: | ||
key = "value" | ||
bare_key = "value" | ||
bare-key = "value" | ||
1234 = "value" | ||
|
||
# Quoted keys: | ||
"127.0.0.1" = "value" | ||
"character encoding" = "value" | ||
"ʎǝʞ" = "value" | ||
'key2' = "value" | ||
'quoted "value"' = "value" | ||
|
||
"key \"containing\" backslash" = 6 | ||
'key \"containing" backslash\' = 6 | ||
|
||
# empty quoted key is allowed | ||
"" = "blank" # VALID but discouraged | ||
'' = 'blank' # VALID but discouraged | ||
|
||
# Dotted keys: | ||
name = "Orange" | ||
physical.color = "orange" | ||
physical.shape = "round" | ||
site."google.com" = true | ||
3.14159 = "pi" | ||
|
||
# Whitespace around dot-separated parts is ignored: | ||
hello . world = "!" | ||
|
||
# Whitespace is ignored around key names and values | ||
hello = "World!" |