Page MenuHomePhabricator

D15882.id38262.diff
No OneTemporary

D15882.id38262.diff

diff --git a/src/xsprintf/__tests__/PhutilCsprintfTestCase.php b/src/xsprintf/__tests__/PhutilCsprintfTestCase.php
--- a/src/xsprintf/__tests__/PhutilCsprintfTestCase.php
+++ b/src/xsprintf/__tests__/PhutilCsprintfTestCase.php
@@ -3,13 +3,30 @@
final class PhutilCsprintfTestCase extends PhutilTestCase {
public function testCommandReadableEscapes() {
- // For arguments comprised of only characters which are safe in any context,
- // %R this should avoid adding quotes.
- $this->assertEqual('ab', (string)csprintf('%R', 'ab'));
-
- // For arguments which have any characters which are not safe in some
- // context, %R should apply standard escaping.
- $this->assertFalse('a b' === (string)csprintf('%R', 'a b'));
+ $inputs = array(
+ // For arguments comprised of only characters which are safe in any
+ // context, %R this should avoid adding quotes.
+ 'ab' => true,
+
+ // For arguments which have any characters which are not safe in some
+ // context, %R should apply standard escaping.
+ 'a b' => false,
+
+
+ 'http://domain.com/path/' => true,
+ 'svn+ssh://domain.com/path/' => true,
+ '`rm -rf`' => false,
+ '$VALUE' => false,
+ );
+
+ foreach ($inputs as $input => $expect_same) {
+ $actual = (string)csprintf('%R', $input);
+ if ($expect_same) {
+ $this->assertEqual($input, $actual);
+ } else {
+ $this->assertFalse($input === $actual);
+ }
+ }
}
public function testPowershell() {
diff --git a/src/xsprintf/csprintf.php b/src/xsprintf/csprintf.php
--- a/src/xsprintf/csprintf.php
+++ b/src/xsprintf/csprintf.php
@@ -107,7 +107,7 @@
break;
case 'R':
- if (!preg_match('(^[a-zA-Z0-9:/@._-]+$)', $value)) {
+ if (!preg_match('(^[a-zA-Z0-9:/@._+-]+$)', $value)) {
$value = PhutilCommandString::escapeArgument($value, $mode);
}
$type = 's';

File Metadata

Mime Type
text/plain
Expires
Thu, Oct 17, 3:10 PM (2 w, 5 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6722513
Default Alt Text
D15882.id38262.diff (1 KB)

Event Timeline