summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test/tst
diff options
context:
space:
mode:
authorDave Borowitz <dborowitz@google.com>2017-12-21 08:55:45 -0500
committerDave Borowitz <dborowitz@google.com>2017-12-21 09:30:52 -0500
commitbe224f8d4c6afb9603c4f824e91e639c9f99cc7a (patch)
tree41b8bab0adfd71523c07b1e621539a868e482548 /org.eclipse.jgit.test/tst
parentfa24425c608e0983580fa81743de9cfda9faac2e (diff)
downloadjgit-be224f8d4c6afb9603c4f824e91e639c9f99cc7a.tar.gz
jgit-be224f8d4c6afb9603c4f824e91e639c9f99cc7a.zip
Config: Drop backslash in invalid escape sequences in subsections
These are ignored by C git when parsing: $ git config -f - --list <<EOF [foo "x\0y"] bar = baz [foo "x\qy"] bar = baz [foo "x\by"] bar = baz [foo "x\ny"] bar = baz [foo "x\ty"] bar = baz EOF foo.x0y.bar=baz foo.xqy.bar=baz foo.xby.bar=baz foo.xny.bar=baz foo.xty.bar=baz This behavior is different from value parsing, where an invalid escape sequence is an error (which JGit already does as well): $ git config -f - --list <<EOF [foo] bar = x\qy EOF fatal: bad config line 2 in standard input Change-Id: Ifd40129b37d9a62df3d886d8d7e22f766f54e9d1
Diffstat (limited to 'org.eclipse.jgit.test/tst')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConfigTest.java17
1 files changed, 9 insertions, 8 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConfigTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConfigTest.java
index a952db764f..2609f6745e 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConfigTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConfigTest.java
@@ -1056,16 +1056,17 @@ public class ConfigTest {
public void testParseInvalidSubsections() {
assertInvalidSubsection(
JGitText.get().newlineInQuotesNotAllowed, "\"x\ny\"");
- assertInvalidSubsection(
- MessageFormat.format(JGitText.get().badEscape, 'q'), "\"x\\q\"");
+ }
+ @Test
+ public void testDropBackslashFromInvalidEscapeSequenceInSubsectionName()
+ throws ConfigInvalidException {
+ assertEquals("x0", parseEscapedSubsection("\"x\\0\""));
+ assertEquals("xq", parseEscapedSubsection("\"x\\q\""));
// Unlike for values, \b, \n, and \t are not valid escape sequences.
- assertInvalidSubsection(
- MessageFormat.format(JGitText.get().badEscape, 'b'), "\"x\\b\"");
- assertInvalidSubsection(
- MessageFormat.format(JGitText.get().badEscape, 'n'), "\"x\\n\"");
- assertInvalidSubsection(
- MessageFormat.format(JGitText.get().badEscape, 't'), "\"x\\t\"");
+ assertEquals("xb", parseEscapedSubsection("\"x\\b\""));
+ assertEquals("xn", parseEscapedSubsection("\"x\\n\""));
+ assertEquals("xt", parseEscapedSubsection("\"x\\t\""));
}
private static void assertValueRoundTrip(String value)