1
0
Fork 0

Merge branch '1.2'

pull/5669/head
Jordi Boggiano 2016-09-12 16:56:32 +02:00
commit 285c4a1ac6
3 changed files with 26 additions and 2 deletions

View File

@ -228,7 +228,24 @@ class GitLabDriver extends VcsDriver
*/ */
public function getApiUrl() public function getApiUrl()
{ {
return $this->scheme.'://'.$this->originUrl.'/api/v3/projects/'.$this->owner.'%2F'.$this->repository; return $this->scheme.'://'.$this->originUrl.'/api/v3/projects/'.$this->urlEncodeAll($this->owner).'%2F'.$this->urlEncodeAll($this->repository);
}
/**
* Urlencode all non alphanumeric characters. rawurlencode() can not be used as it does not encode `.`
*
* @param string $string
* @return string
*/
private function urlEncodeAll($string)
{
$encoded = '';
for ($i = 0; isset($string[$i]); $i++) {
$character = $string[$i];
if (!ctype_alnum($character)) $character = '%' . sprintf('%02X', ord($character));
$encoded .= $character;
}
return $encoded;
} }
/** /**

View File

@ -444,7 +444,8 @@ class Filesystem
$prefix = ''; $prefix = '';
$absolute = false; $absolute = false;
if (preg_match('{^([0-9a-z]+:(?://(?:[a-z]:)?)?)}i', $path, $match)) { // extract a prefix being a protocol://, protocol:, protocol://drive: or simply drive:
if (preg_match('{^( [0-9a-z]{2,}+: (?: // (?: [a-z]: )? )? | [a-z]: )}ix', $path, $match)) {
$prefix = $match[1]; $prefix = $match[1];
$path = substr($path, strlen($prefix)); $path = substr($path, strlen($prefix));
} }

View File

@ -204,12 +204,18 @@ class FilesystemTest extends TestCase
array('../foo', '../foo'), array('../foo', '../foo'),
array('c:/foo/bar', 'c:/foo//bar'), array('c:/foo/bar', 'c:/foo//bar'),
array('C:/foo/bar', 'C:/foo/./bar'), array('C:/foo/bar', 'C:/foo/./bar'),
array('C:/foo/bar', 'C://foo//bar'),
array('C:/foo/bar', 'C:///foo//bar'),
array('C:/bar', 'C:/foo/../bar'), array('C:/bar', 'C:/foo/../bar'),
array('/bar', '/foo/../bar/'), array('/bar', '/foo/../bar/'),
array('phar://c:/Foo', 'phar://c:/Foo/Bar/..'), array('phar://c:/Foo', 'phar://c:/Foo/Bar/..'),
array('phar://c:/Foo', 'phar://c:///Foo/Bar/..'),
array('phar://c:/', 'phar://c:/Foo/Bar/../../../..'), array('phar://c:/', 'phar://c:/Foo/Bar/../../../..'),
array('/', '/Foo/Bar/../../../..'), array('/', '/Foo/Bar/../../../..'),
array('/', '/'), array('/', '/'),
array('/', '//'),
array('/', '///'),
array('/Foo', '///Foo'),
array('c:/', 'c:\\'), array('c:/', 'c:\\'),
array('../src', 'Foo/Bar/../../../src'), array('../src', 'Foo/Bar/../../../src'),
array('c:../b', 'c:.\\..\\a\\..\\b'), array('c:../b', 'c:.\\..\\a\\..\\b'),