diff options
author | Shawn O. Pearce <spearce@spearce.org> | 2010-09-03 13:01:57 -0700 |
---|---|---|
committer | Shawn O. Pearce <spearce@spearce.org> | 2010-09-03 13:02:01 -0700 |
commit | 2aa4196f1fd02851976d2c214302d87ea26663d0 (patch) | |
tree | 4c65dafa491d9b9a82ac60b98d1b2ce34d9b2cba /org.eclipse.jgit.test/tst/org/eclipse/jgit/util | |
parent | 34a755f1df959bd34f9426143765e650665b1afb (diff) | |
download | jgit-2aa4196f1fd02851976d2c214302d87ea26663d0.tar.gz jgit-2aa4196f1fd02851976d2c214302d87ea26663d0.zip |
Fix QuotedString.GIT_PATH escaping rules
We shouldn't escape non-special ASCII characters such as '@' or '~'.
These are valid in a path name on POSIX systems, and may appear as
part of a path in a GNU or Git style patch script. Escaping them
into octal just obfuscates the user's intent, with no gain.
When parsing an escaped octal sequence, we must parse no more
than 3 digits. That is, "\1002" is actually "@2", not the Unicode
character \u0202.
Change-Id: I3a849a0d318e69b654f03fd559f5d7f99dd63e5c
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'org.eclipse.jgit.test/tst/org/eclipse/jgit/util')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/util/QuotedStringGitPathStyleTest.java | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/QuotedStringGitPathStyleTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/QuotedStringGitPathStyleTest.java index 4a161fa01c..1af45c2272 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/QuotedStringGitPathStyleTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/QuotedStringGitPathStyleTest.java @@ -153,7 +153,7 @@ public class QuotedStringGitPathStyleTest extends TestCase { public void testQuote_OctalAll() { assertQuote("\\001", "\1"); - assertQuote("\\176", "~"); + assertQuote("\\177", "\u007f"); assertQuote("\\303\\277", "\u00ff"); // \u00ff in UTF-8 } @@ -184,4 +184,9 @@ public class QuotedStringGitPathStyleTest extends TestCase { public void testQuote_Ang() { assertQuote("\\303\\205ngstr\\303\\266m", "\u00c5ngstr\u00f6m"); } + + public void testQuoteAtAndNumber() { + assertSame("abc@2x.png", GIT_PATH.quote("abc@2x.png")); + assertDequote("abc@2x.png", "abc\\1002x.png"); + } } |