Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix URL helpers to recognize protocol-relative URLs. #2059

Merged
merged 2 commits into from
Dec 8, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions system/helpers/url_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ function anchor($uri = '', $title = '', $attributes = '')

if ( ! is_array($uri))
{
$site_url = preg_match('!^\w+://! i', $uri) ? $uri : site_url($uri);
$site_url = preg_match('#^(\w+:)?//#i', $uri) ? $uri : site_url($uri);
}
else
{
Expand Down Expand Up @@ -191,7 +191,7 @@ function anchor($uri = '', $title = '', $attributes = '')
function anchor_popup($uri = '', $title = '', $attributes = FALSE)
{
$title = (string) $title;
$site_url = preg_match('!^\w+://! i', $uri) ? $uri : site_url($uri);
$site_url = preg_match('#^(\w+:)?//#i', $uri) ? $uri : site_url($uri);

if ($title === '')
{
Expand Down Expand Up @@ -535,7 +535,7 @@ function url_title($str, $separator = '-', $lowercase = FALSE)
*/
function redirect($uri = '', $method = 'auto', $code = NULL)
{
if ( ! preg_match('#^https?://#i', $uri))
if ( ! preg_match('#^(\w+:)?//#i', $uri))
{
$uri = site_url($uri);
}
Expand Down
1 change: 1 addition & 0 deletions user_guide_src/source/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ Release Date: Not Released
- Added JS window name support to the :php:func:`anchor_popup()` function.
- Added support (auto-detection) for HTTP/1.1 response code 303 in :php:func:`redirect()`.
- Changed :php:func:`redirect()` to only choose the **refresh** method only on IIS servers, instead of all servers on Windows (when **auto** is used).
- Changed :php:func:`anchor()`, :php:func:`anchor_popup()`, and :php:func:`redirect()` to support protocol-relative URLs, such as `redirect('//ellislab.com/codeigniter')`.
- Added XHTML Basic 1.1 doctype to :doc:`HTML Helper <helpers/html_helper>`.
- :doc:`Inflector Helper <helpers/inflector_helper>` changes include:
- Changed :php:func:`humanize()` to allow passing an input separator as its second parameter.
Expand Down