12 * obtain it through the world-wide-web, please send an email |
12 * obtain it through the world-wide-web, please send an email |
13 * to license@zend.com so we can send you a copy immediately. |
13 * to license@zend.com so we can send you a copy immediately. |
14 * |
14 * |
15 * @category Zend |
15 * @category Zend |
16 * @package Zend_Uri |
16 * @package Zend_Uri |
17 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
17 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
18 * @license http://framework.zend.com/license/new-bsd New BSD License |
18 * @license http://framework.zend.com/license/new-bsd New BSD License |
19 * @version $Id: Http.php 23409 2010-11-19 19:55:25Z bittarman $ |
19 * @version $Id: Http.php 24593 2012-01-05 20:35:02Z matthew $ |
20 */ |
20 */ |
21 |
21 |
22 /** |
22 /** |
23 * @see Zend_Uri |
23 * @see Zend_Uri |
24 */ |
24 */ |
215 $this->_query = isset($matches[6]) === true ? $matches[6] : ''; |
215 $this->_query = isset($matches[6]) === true ? $matches[6] : ''; |
216 $this->_fragment = isset($matches[8]) === true ? $matches[8] : ''; |
216 $this->_fragment = isset($matches[8]) === true ? $matches[8] : ''; |
217 |
217 |
218 // Additional decomposition to get username, password, host, and port |
218 // Additional decomposition to get username, password, host, and port |
219 $combo = isset($matches[3]) === true ? $matches[3] : ''; |
219 $combo = isset($matches[3]) === true ? $matches[3] : ''; |
220 $pattern = '~^(([^:@]*)(:([^@]*))?@)?([^:]+)(:(.*))?$~'; |
220 $pattern = '~^(([^:@]*)(:([^@]*))?@)?((?(?=[[])[[][^]]+[]]|[^:]+))(:(.*))?$~'; |
221 $status = @preg_match($pattern, $combo, $matches); |
221 $status = @preg_match($pattern, $combo, $matches); |
222 if ($status === false) { |
222 if ($status === false) { |
223 require_once 'Zend/Uri/Exception.php'; |
223 require_once 'Zend/Uri/Exception.php'; |
224 throw new Zend_Uri_Exception('Internal error: authority decomposition failed'); |
224 throw new Zend_Uri_Exception('Internal error: authority decomposition failed'); |
225 } |
225 } |
226 |
226 |
227 // Failed decomposition; no further processing needed |
|
228 if ($status === false) { |
|
229 return; |
|
230 } |
|
231 |
|
232 // Save remaining URI components |
227 // Save remaining URI components |
233 $this->_username = isset($matches[2]) === true ? $matches[2] : ''; |
228 $this->_username = isset($matches[2]) === true ? $matches[2] : ''; |
234 $this->_password = isset($matches[4]) === true ? $matches[4] : ''; |
229 $this->_password = isset($matches[4]) === true ? $matches[4] : ''; |
235 $this->_host = isset($matches[5]) === true ? $matches[5] : ''; |
230 $this->_host = isset($matches[5]) === true |
|
231 ? preg_replace('~^\[([^]]+)\]$~', '\1', $matches[5]) // Strip wrapper [] from IPv6 literal |
|
232 : ''; |
236 $this->_port = isset($matches[7]) === true ? $matches[7] : ''; |
233 $this->_port = isset($matches[7]) === true ? $matches[7] : ''; |
237 |
|
238 } |
234 } |
239 |
235 |
240 /** |
236 /** |
241 * Returns a URI based on current values of the instance variables. If any |
237 * Returns a URI based on current values of the instance variables. If any |
242 * part of the URI does not pass validation, then an exception is thrown. |
238 * part of the URI does not pass validation, then an exception is thrown. |