@@ -428,6 +428,26 @@ def test_config_with_quotes_with_whitespace_outside_value(self):
428
428
cr = GitConfigParser (fixture_path ("git_config_with_quotes_whitespace_outside" ), read_only = True )
429
429
self .assertEqual (cr .get ("init" , "defaultBranch" ), "trunk" )
430
430
431
+ def test_config_with_quotes_containing_escapes (self ):
432
+ """For now just suppress quote removal. But it would be good to interpret most of these."""
433
+ cr = GitConfigParser (fixture_path ("git_config_with_quotes_escapes" ), read_only = True )
434
+
435
+ # These can eventually be supported by substituting the represented character.
436
+ self .assertEqual (cr .get ("custom" , "hasnewline" ), R'"first\nsecond"' )
437
+ self .assertEqual (cr .get ("custom" , "hasbackslash" ), R'"foo\\bar"' )
438
+ self .assertEqual (cr .get ("custom" , "hasquote" ), R'"ab\"cd"' )
439
+ self .assertEqual (cr .get ("custom" , "hastrailingbackslash" ), R'"word\\"' )
440
+ self .assertEqual (cr .get ("custom" , "hasunrecognized" ), R'"p\qrs"' )
441
+
442
+ # It is less obvious whether and what to eventually do with this.
443
+ self .assertEqual (cr .get ("custom" , "hasunescapedquotes" ), '"ab"cd"e"' )
444
+
445
+ # Cases where quote removal is clearly safe should happen even after those.
446
+ self .assertEqual (cr .get ("custom" , "ordinary" ), "hello world" )
447
+
448
+ # Cases without quotes should still parse correctly even after those, too.
449
+ self .assertEqual (cr .get ("custom" , "unquoted" ), "good evening" )
450
+
431
451
def test_get_values_works_without_requiring_any_other_calls_first (self ):
432
452
file_obj = self ._to_memcache (fixture_path ("git_config_multiple" ))
433
453
cr = GitConfigParser (file_obj , read_only = True )
0 commit comments