summaryrefslogtreecommitdiffstats
path: root/user_guide_src
diff options
context:
space:
mode:
authorAndrey Andreev <narf@bofh.bg>2012-10-30 12:42:01 +0100
committerAndrey Andreev <narf@bofh.bg>2012-10-30 12:42:01 +0100
commit7676c2d6761cb3cdeccf005c2a30140f0ba3ced5 (patch)
treeb9af3d1cdf2523bc8e863c2a9b2abd47797a74f0 /user_guide_src
parent0dfb62ff0ab1d184e20819a066139fea28d68da4 (diff)
Fix issue #658 (:any wildcard matching slashes)
Diffstat (limited to 'user_guide_src')
-rw-r--r--user_guide_src/source/changelog.rst1
-rw-r--r--user_guide_src/source/general/routing.rst30
-rw-r--r--user_guide_src/source/installation/upgrade_300.rst40
3 files changed, 57 insertions, 14 deletions
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index c7f72f609..5b3ca3e9f 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -399,6 +399,7 @@ Bug fixes for 3.0
- Fixed a bug (#1630) - :doc:`Form Helper <helpers/form_helper>` function ``set_value()`` didn't escape HTML entities.
- Fixed a bug (#142) - :doc:`Form Helper <helpers/form_helper>` function ``form_dropdown()`` didn't escape HTML entities in option values.
- Fixed a bug (#50) - :doc:`Session Library <libraries/sessions>` unnecessarily stripped slashed from serialized data, making it impossible to read objects in a namespace.
+- Fixed a bug (#658) - :doc:`Routing <general/routing>` wildcard **:any** didn't work as advertised and matched multiple URI segments instead of all characters within a single segment.
Version 2.1.3
=============
diff --git a/user_guide_src/source/general/routing.rst b/user_guide_src/source/general/routing.rst
index c03937070..a6332c90c 100644
--- a/user_guide_src/source/general/routing.rst
+++ b/user_guide_src/source/general/routing.rst
@@ -29,7 +29,7 @@ Setting your own routing rules
Routing rules are defined in your application/config/routes.php file. In
it you'll see an array called $route that permits you to specify your
own routing criteria. Routes can either be specified using wildcards or
-Regular Expressions
+Regular Expressions.
Wildcards
=========
@@ -47,7 +47,11 @@ segment of the URL, and a number is found in the second segment, the
You can match literal values or you can use two wildcard types:
**(:num)** will match a segment containing only numbers.
-**(:any)** will match a segment containing any character.
+**(:any)** will match a segment containing any character (except for '/', which is the segment delimiter).
+
+.. note:: Wildcards are actually aliases for regular expressions, with
+ **:any** being translated to **[^/]+** and **:num** to **[0-9]+**,
+ respectively.
.. note:: Routes will run in the order they are defined. Higher routes
will always take precedence over lower ones.
@@ -104,12 +108,28 @@ rules. Any valid regular expression is allowed, as are back-references.
A typical RegEx route might look something like this::
- $route['products/([a-z]+)/(\d+)'] = "$1/id_$2";
+ $route['products/([a-z]+)/(\d+)'] = '$1/id_$2';
In the above example, a URI similar to products/shirts/123 would instead
-call the shirts controller class and the id_123 function.
+call the shirts controller class and the id_123 method.
+
+With regular expressions, you can also catch a segment containing a
+forward slash ('/'), which would usually represent the delimiter between
+multiple segments.
+For example, if a user accesses a password protected area of your web
+application and you wish to be able to redirect them back to the same
+page after they log in, you may find this example useful::
+
+ $route['login/(.+)'] = 'auth/login/$1';
+
+That will call the auth controller class and its ``login()`` method,
+passing everything contained in the URI after *login/* as a parameter.
+
+For those of you who don't know regular expressions and want to learn
+more about them, `regular-expressions.info <http://www.regular-expressions.info/>`
+might be a good starting point.
-You can also mix and match wildcards with regular expressions.
+..note:: You can also mix and match wildcards with regular expressions.
Reserved Routes
===============
diff --git a/user_guide_src/source/installation/upgrade_300.rst b/user_guide_src/source/installation/upgrade_300.rst
index dcdd6e351..6d99f4655 100644
--- a/user_guide_src/source/installation/upgrade_300.rst
+++ b/user_guide_src/source/installation/upgrade_300.rst
@@ -52,11 +52,12 @@ Step 5: Update your config/database.php
***************************************
Due to 3.0.0's renaming of Active Record to Query Builder, inside your `config/database.php`, you will
-need to rename the `$active_record` variable to `$query_builder`.
+need to rename the `$active_record` variable to `$query_builder`
+::
- $active_group = 'default';
- // $active_record = TRUE;
- $query_builder = TRUE;
+ $active_group = 'default';
+ // $active_record = TRUE;
+ $query_builder = TRUE;
*******************************
Step 6: Move your errors folder
@@ -64,15 +65,36 @@ Step 6: Move your errors folder
In version 3.0.0, the errors folder has been moved from _application/errors* to _application/views/errors*.
+*******************************************************
+Step 7: Update your config/routes.php containing (:any)
+*******************************************************
+
+Historically, CodeIgniter has always provided the **:any** wildcard in routing,
+with the intention of providing a way to match any character **within** an URI segment.
+
+However, the **:any** wildcard is actually just an alias for a regular expression
+and used to be executed in that manner as **.+**. This is considered a bug, as it
+also matches the / (forward slash) character, which is the URI segment delimiter
+and that was never the intention. In CodeIgniter 3, the **:any** wildcard will now
+represent **[^/]+**, so that it will not match a forward slash.
+
+There are certainly many developers that have utilized this bug as an actual feature.
+If you're one of them and want to match a forward slash, please use the **.+**
+regular expression::
+
+ (.+) // matches ANYTHING
+ (:any) // matches any character, except for '/'
+
+
****************************************************************************
-Step 7: Check the calls to Array Helper's element() and elements() functions
+Step 8: Check the calls to Array Helper's element() and elements() functions
****************************************************************************
The default return value of these functions, when the required elements
don't exist, has been changed from FALSE to NULL.
**********************************************************
-Step 8: Change usage of Email library with multiple emails
+Step 9: Change usage of Email library with multiple emails
**********************************************************
The :doc:`Email library <../libraries/email>` will automatically clear the
@@ -87,9 +109,9 @@ pass FALSE as the first parameter in the ``send()`` method:
}
-***************************************************************
-Step 9: Remove usage of (previously) deprecated functionalities
-***************************************************************
+****************************************************************
+Step 10: Remove usage of (previously) deprecated functionalities
+****************************************************************
In addition to the ``$autoload['core']`` configuration setting, there's a number of other functionalities
that have been removed in CodeIgniter 3.0.0: