Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf2b8041

Browse files
committed
Don't remove quotes if\ or" are present inside
This is for single line quoting in the ConfigParser.This leaves the changes in#2035 (as adjusted in#2036) intact forthe cases where it addressed#1923: when the `...` in `"..."`(appearing in the value position on a single `{name} = {value}"`line) has no occurrences of `\` or `"`, quote removal is enough.But when `\` or `"` does appear, this suppresses quote removal.This is with the idea that, while it would be better to interpretsuch lines as Git does, we do not yet do that, so it is preferableto return the same results we have in the past (which some programsmay already be handling themselves).This should make the test introduced in the preceding commit pass.But it will be even better to support more syntax, at leastwell-formed escapes. As noted in the test, both the test and thecode under test can be adjusted for that.(See comments in#2035 for context.)
1 parent7bcea08 commitf2b8041

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

‎git/config.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -505,13 +505,16 @@ def string_decode(v: str) -> str:
505505
optval=optval.strip()
506506

507507
iflen(optval)<2oroptval[0]!='"':
508-
pass# Nothing to treat as opening quotation.
508+
# Does not open quoting.
509+
pass
509510
elifoptval[-1]!='"':
511+
# Opens quoting and does not close: appears to start multi-line quoting.
510512
is_multi_line=True
511513
optval=string_decode(optval[1:])
512-
# END handle multi-line
513-
else:
514+
elifoptval.find("\\",1,-1)==-1andoptval.find('"',1,-1)==-1:
515+
# Opens and closes quoting. Single line, and all we need is quote removal.
514516
optval=optval[1:-1]
517+
# TODO: Handle other quoted content, especially well-formed backslash escapes.
515518

516519
# Preserves multiple values for duplicate optnames.
517520
cursect.add(optname,optval)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp