当前位置: 首页>>代码示例>>PHP>>正文


PHP PhutilURI::getPass方法代码示例

本文整理汇总了PHP中PhutilURI::getPass方法的典型用法代码示例。如果您正苦于以下问题:PHP PhutilURI::getPass方法的具体用法?PHP PhutilURI::getPass怎么用?PHP PhutilURI::getPass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PhutilURI的用法示例。


在下文中一共展示了PhutilURI::getPass方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的PhutilURI::getPass方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。