Révision bceb9b7a
Ajouté par Florent Torregrosa il y a environ 9 ans
drupal7/modules/simpletest/tests/common.test | ||
---|---|---|
209 | 209 |
// Test that drupal can recognize an absolute URL. Used to prevent attack vectors. |
210 | 210 |
$this->assertTrue(url_is_external($url), 'Correctly identified an external URL.'); |
211 | 211 |
|
212 |
// External URL without an explicit protocol. |
|
213 |
$url = '//drupal.org/foo/bar?foo=bar&bar=baz&baz#foo'; |
|
214 |
$this->assertTrue(url_is_external($url), 'Correctly identified an external URL without a protocol part.'); |
|
215 |
|
|
216 |
// Internal URL starting with a slash. |
|
217 |
$url = '/drupal.org'; |
|
218 |
$this->assertFalse(url_is_external($url), 'Correctly identified an internal URL with a leading slash.'); |
|
219 |
|
|
212 | 220 |
// Test the parsing of absolute URLs. |
221 |
$url = 'http://drupal.org/foo/bar?foo=bar&bar=baz&baz#foo'; |
|
213 | 222 |
$result = array( |
214 | 223 |
'path' => 'http://drupal.org/foo/bar', |
215 | 224 |
'query' => array('foo' => 'bar', 'bar' => 'baz', 'baz' => ''), |
... | ... | |
349 | 358 |
$query = array($this->randomName(5) => $this->randomName(5)); |
350 | 359 |
$result = url($url, array('query' => $query)); |
351 | 360 |
$this->assertEqual($url . '&' . http_build_query($query, '', '&'), $result, 'External URL query string can be extended with a custom query string in $options.'); |
361 |
|
|
362 |
// Verify that an internal URL does not result in an external URL without |
|
363 |
// protocol part. |
|
364 |
$url = '/drupal.org'; |
|
365 |
$result = url($url); |
|
366 |
$this->assertTrue(strpos($result, '//') === FALSE, 'Internal URL does not turn into an external URL.'); |
|
367 |
|
|
368 |
// Verify that an external URL without protocol part is recognized as such. |
|
369 |
$url = '//drupal.org'; |
|
370 |
$result = url($url); |
|
371 |
$this->assertEqual($url, $result, 'External URL without protocol is not altered.'); |
|
352 | 372 |
} |
353 | 373 |
} |
354 | 374 |
|
Formats disponibles : Unified diff
Update core to 7.35