當前位置: 首頁>>代碼示例>>PHP>>正文


PHP PhutilURI::getUser方法代碼示例

本文整理匯總了PHP中PhutilURI::getUser方法的典型用法代碼示例。如果您正苦於以下問題:PHP PhutilURI::getUser方法的具體用法?PHP PhutilURI::getUser怎麽用?PHP PhutilURI::getUser使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PhutilURI的用法示例。


在下文中一共展示了PhutilURI::getUser方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testURIParsing

 public function testURIParsing()
 {
     $uri = new PhutilURI('http://user:pass@host:99/path/?query=value#fragment');
     $this->assertEqual('http', $uri->getProtocol(), pht('protocol'));
     $this->assertEqual('user', $uri->getUser(), pht('user'));
     $this->assertEqual('pass', $uri->getPass(), pht('password'));
     $this->assertEqual('host', $uri->getDomain(), pht('domain'));
     $this->assertEqual('99', $uri->getPort(), pht('port'));
     $this->assertEqual('/path/', $uri->getPath(), pht('path'));
     $this->assertEqual(array('query' => 'value'), $uri->getQueryParams(), 'query params');
     $this->assertEqual('fragment', $uri->getFragment(), pht('fragment'));
     $this->assertEqual('http://user:pass@host:99/path/?query=value#fragment', (string) $uri, 'uri');
     $uri = new PhutilURI('ssh://git@example.com/example/example.git');
     $this->assertEqual('ssh', $uri->getProtocol(), pht('protocol'));
     $this->assertEqual('git', $uri->getUser(), pht('user'));
     $this->assertEqual('', $uri->getPass(), pht('password'));
     $this->assertEqual('example.com', $uri->getDomain(), pht('domain'));
     $this->assertEqual('', $uri->getPort(), 'port');
     $this->assertEqual('/example/example.git', $uri->getPath(), pht('path'));
     $this->assertEqual(array(), $uri->getQueryParams(), pht('query parameters'));
     $this->assertEqual('', $uri->getFragment(), pht('fragment'));
     $this->assertEqual('ssh://git@example.com/example/example.git', (string) $uri, 'uri');
     $uri = new PhutilURI('http://0@domain.com/');
     $this->assertEqual('0', $uri->getUser());
     $this->assertEqual('http://0@domain.com/', (string) $uri);
     $uri = new PhutilURI('http://0:0@domain.com/');
     $this->assertEqual('0', $uri->getUser());
     $this->assertEqual('0', $uri->getPass());
     $this->assertEqual('http://0:0@domain.com/', (string) $uri);
     $uri = new PhutilURI('http://%20:%20@domain.com/');
     $this->assertEqual(' ', $uri->getUser());
     $this->assertEqual(' ', $uri->getPass());
     $this->assertEqual('http://%20:%20@domain.com/', (string) $uri);
     $uri = new PhutilURI('http://%40:%40@domain.com/');
     $this->assertEqual('@', $uri->getUser());
     $this->assertEqual('@', $uri->getPass());
     $this->assertEqual('http://%40:%40@domain.com/', (string) $uri);
     // These tests are covering cases where cURL and parse_url() behavior
     // may differ in potentially dangerous ways. See T6755 for discussion.
     // In general, we defuse these attacks by emitting URIs which escape
     // special characters so that they are interpreted unambiguously by
     // cURL in the same way that parse_url() interpreted them.
     $uri = new PhutilURI('http://u:p@evil.com?@good.com');
     $this->assertEqual('u', $uri->getUser());
     $this->assertEqual('p', $uri->getPass());
     $this->assertEqual('evil.com', $uri->getDomain());
     $this->assertEqual('http://u:p@evil.com?%40good.com=', (string) $uri);
     $uri = new PhutilURI('http://good.com#u:p@evil.com/');
     $this->assertEqual('good.com#u', $uri->getUser());
     $this->assertEqual('p', $uri->getPass());
     $this->assertEqual('evil.com', $uri->getDomain());
     $this->assertEqual('http://good.com%23u:p@evil.com/', (string) $uri);
     $uri = new PhutilURI('http://good.com?u:p@evil.com/');
     $this->assertEqual('', $uri->getUser());
     $this->assertEqual('', $uri->getPass());
     $this->assertEqual('good.com', $uri->getDomain());
     $this->assertEqual('http://good.com?u%3Ap%40evil.com%2F=', (string) $uri);
 }
開發者ID:barcelonascience,項目名稱:libphutil,代碼行數:58,代碼來源:PhutilURITestCase.php

示例2: testURIParsing

 public function testURIParsing()
 {
     $uri = new PhutilURI('http://user:pass@host:99/path/?query=value#fragment');
     $this->assertEqual('http', $uri->getProtocol(), 'protocol');
     $this->assertEqual('user', $uri->getUser(), 'user');
     $this->assertEqual('pass', $uri->getPass(), 'pass');
     $this->assertEqual('host', $uri->getDomain(), 'domain');
     $this->assertEqual('99', $uri->getPort(), 'port');
     $this->assertEqual('/path/', $uri->getPath(), 'path');
     $this->assertEqual(array('query' => 'value'), $uri->getQueryParams(), 'query params');
     $this->assertEqual('fragment', $uri->getFragment(), 'fragment');
     $this->assertEqual('http://user:pass@host:99/path/?query=value#fragment', (string) $uri, 'uri');
     $uri = new PhutilURI('ssh://git@example.com/example/example.git');
     $this->assertEqual('ssh', $uri->getProtocol(), 'protocol');
     $this->assertEqual('git', $uri->getUser(), 'user');
     $this->assertEqual('', $uri->getPass(), 'pass');
     $this->assertEqual('example.com', $uri->getDomain(), 'domain');
     $this->assertEqual('', $uri->getPort(), 'port');
     $this->assertEqual('/example/example.git', $uri->getPath(), 'path');
     $this->assertEqual(array(), $uri->getQueryParams(), 'query params');
     $this->assertEqual('', $uri->getFragment(), 'fragment');
     $this->assertEqual('ssh://git@example.com/example/example.git', (string) $uri, 'uri');
     $uri = new PhutilURI('http://0@domain.com/');
     $this->assertEqual('0', $uri->getUser());
     $this->assertEqual('http://0@domain.com/', (string) $uri);
     $uri = new PhutilURI('http://0:0@domain.com/');
     $this->assertEqual('0', $uri->getUser());
     $this->assertEqual('0', $uri->getPass());
     $this->assertEqual('http://0:0@domain.com/', (string) $uri);
     $uri = new PhutilURI('http://%20:%20@domain.com/');
     $this->assertEqual(' ', $uri->getUser());
     $this->assertEqual(' ', $uri->getPass());
     $this->assertEqual('http://%20:%20@domain.com/', (string) $uri);
     $uri = new PhutilURI('http://%40:%40@domain.com/');
     $this->assertEqual('@', $uri->getUser());
     $this->assertEqual('@', $uri->getPass());
     $this->assertEqual('http://%40:%40@domain.com/', (string) $uri);
 }
開發者ID:lsubra,項目名稱:libphutil,代碼行數:38,代碼來源:PhutilURITestCase.php

示例3: getRemoteURIUser

 private function getRemoteURIUser($raw_uri)
 {
     $uri = new PhutilURI($raw_uri);
     if ($uri->getUser()) {
         return $uri->getUser();
     }
     $git_uri = new PhutilGitURI($raw_uri);
     if (strlen($git_uri->getDomain()) && strlen($git_uri->getPath())) {
         return $git_uri->getUser();
     }
     return null;
 }
開發者ID:denghp,項目名稱:phabricator,代碼行數:12,代碼來源:DiffusionRepositoryCreateController.php

示例4: pht

 if (!$raw_uri) {
     echo pht('...no remote URI.') . "\n";
     continue;
 }
 $uri = new PhutilURI($raw_uri);
 $proto = strtolower($uri->getProtocol());
 if ($proto == 'http' || $proto == 'https' || $proto == 'svn') {
     $username = $repository->getDetail('http-login');
     $secret = $repository->getDetail('http-pass');
     $type = PassphrasePasswordCredentialType::CREDENTIAL_TYPE;
 } else {
     $username = $repository->getDetail('ssh-login');
     if (!$username) {
         // If there's no explicit username, check for one in the URI. This is
         // possible with older repositories.
         $username = $uri->getUser();
         if (!$username) {
             // Also check for a Git/SCP-style URI.
             $git_uri = new PhutilGitURI($raw_uri);
             $username = $git_uri->getUser();
         }
     }
     $file = $repository->getDetail('ssh-keyfile');
     if ($file) {
         $secret = $file;
         $type = PassphraseSSHPrivateKeyFileCredentialType::CREDENTIAL_TYPE;
     } else {
         $secret = $repository->getDetail('ssh-key');
         $type = PassphraseSSHPrivateKeyTextCredentialType::CREDENTIAL_TYPE;
     }
 }
開發者ID:hrb518,項目名稱:phabricator,代碼行數:31,代碼來源:20131121.repocredentials.2.mig.php

示例5: testGitURIParsing

 public function testGitURIParsing()
 {
     $uri = new PhutilURI('git@host.com:path/to/something');
     $this->assertEqual('ssh', $uri->getProtocol());
     $this->assertEqual('git', $uri->getUser());
     $this->assertEqual('host.com', $uri->getDomain());
     $this->assertEqual('path/to/something', $uri->getPath());
     $this->assertEqual('git@host.com:path/to/something', (string) $uri);
     $uri = new PhutilURI('host.com:path/to/something');
     $this->assertEqual('ssh', $uri->getProtocol());
     $this->assertEqual('', $uri->getUser());
     $this->assertEqual('host.com', $uri->getDomain());
     $this->assertEqual('path/to/something', $uri->getPath());
     $this->assertEqual('host.com:path/to/something', (string) $uri);
     $uri_1 = new PhutilURI('host.com:path/to/something');
     $uri_2 = new PhutilURI($uri_1);
     $this->assertEqual((string) $uri_1, (string) $uri_2);
 }
開發者ID:endlessm,項目名稱:libphutil,代碼行數:18,代碼來源:PhutilURITestCase.php


注:本文中的PhutilURI::getUser方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。