From 9bea4be2efa74b963d3cd0bbaa4635deffc2f109 Mon Sep 17 00:00:00 2001 From: GDmac Date: Tue, 30 Oct 2012 06:14:19 +0100 Subject: Fix #1938 Where the email library removed multiple spaces inside a plain text message. Signed-off-by: GDmac --- system/libraries/Email.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/system/libraries/Email.php b/system/libraries/Email.php index edca303ff..7280466a5 100644 --- a/system/libraries/Email.php +++ b/system/libraries/Email.php @@ -770,6 +770,9 @@ class CI_Email { $body = str_replace(str_repeat("\n", $i), "\n\n", $body); } + // Reduce multiple spaces + $str = preg_replace('| +|', ' ', $str); + return ($this->wordwrap) ? $this->word_wrap($body, 76) : $body; @@ -792,15 +795,15 @@ class CI_Email { $charlim = empty($this->wrapchars) ? 76 : $this->wrapchars; } - // Reduce multiple spaces - $str = preg_replace('| +|', ' ', $str); - // Standardize newlines if (strpos($str, "\r") !== FALSE) { $str = str_replace(array("\r\n", "\r"), "\n", $str); } + // Reduce multiple spaces at end of line + $str = preg_replace('| +\n|', "\n", $str); + // If the current word is surrounded by {unwrap} tags we'll // strip the entire chunk and replace it with a marker. $unwrap = array(); -- cgit v1.2.3-24-g4f1b From 759d322a2e7d16278dede0eeafb86f5e5ea1ddc0 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 30 Oct 2012 11:30:47 +0200 Subject: [ci skip] Alter a changelog entry for 2.1.3 --- user_guide_src/source/changelog.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 4b161dc2d..c7f72f609 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -413,7 +413,7 @@ Bug fixes for 2.1.3 - Fixed a bug (#1543) - File-based :doc:`Caching ` method ``get_metadata()`` used a non-existent array key to look for the TTL value. - Fixed a bug (#1314) - :doc:`Session Library ` method ``sess_destroy()`` didn't destroy the userdata array. -- Fixed a bug (#804) - Profiler library was trying to handle objects as strings in some cases, resulting in *E_WARNING* messages being issued by ``htmlspecialchars()``. +- Fixed a bug (#804) - :doc:`Profiler library ` was trying to handle objects as strings in some cases, resulting in *E_WARNING* messages being issued by ``htmlspecialchars()``. - Fixed a bug (#1699) - :doc:`Migration Library ` ignored the ``$config['migration_path']`` setting. - Fixed a bug (#227) - :doc:`Input Library ` allowed unconditional spoofing of HTTP clients' IP addresses through the *HTTP_CLIENT_IP* header. - Fixed a bug (#907) - :doc:`Input Library ` ignored *HTTP_X_CLUSTER_CLIENT_IP* and *HTTP_X_CLIENT_IP* headers when checking for proxies. -- cgit v1.2.3-24-g4f1b From afca803c1a9212575c9a6454d5a648d1170da91d Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 30 Oct 2012 11:37:15 +0200 Subject: [ci skip] Fix a note in the QB documentation --- user_guide_src/source/database/query_builder.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/user_guide_src/source/database/query_builder.rst b/user_guide_src/source/database/query_builder.rst index 5380d0998..61cd7dfed 100644 --- a/user_guide_src/source/database/query_builder.rst +++ b/user_guide_src/source/database/query_builder.rst @@ -492,8 +492,8 @@ Or multiple function calls can be made if you need multiple fields. .. note:: order_by() was formerly known as orderby(), which has been removed. -.. note:: random ordering is not currently supported in Oracle or MSSQL - drivers. These will default to 'ASC'. +.. note:: Random ordering is not currently supported in Oracle and + will default to ASC instead. $this->db->limit() ================== -- cgit v1.2.3-24-g4f1b From ed1741125d638cfaa1bb2918b7f140f282a107de Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 30 Oct 2012 13:42:01 +0200 Subject: Fix issue #658 (:any wildcard matching slashes) --- system/core/Router.php | 2 +- user_guide_src/source/changelog.rst | 1 + user_guide_src/source/general/routing.rst | 30 +++++++++++++--- user_guide_src/source/installation/upgrade_300.rst | 40 +++++++++++++++++----- 4 files changed, 58 insertions(+), 15 deletions(-) diff --git a/system/core/Router.php b/system/core/Router.php index efee2439f..a5e29f1a3 100644 --- a/system/core/Router.php +++ b/system/core/Router.php @@ -368,7 +368,7 @@ class CI_Router { foreach ($this->routes as $key => $val) { // Convert wild-cards to RegEx - $key = str_replace(array(':any', ':num'), array('.+', '[0-9]+'), $key); + $key = str_replace(array(':any', ':num'), array('[^/]+', '[0-9]+'), $key); // Does the RegEx match? if (preg_match('#^'.$key.'$#', $uri)) 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 ` function ``set_value()`` didn't escape HTML entities. - Fixed a bug (#142) - :doc:`Form Helper ` function ``form_dropdown()`` didn't escape HTML entities in option values. - Fixed a bug (#50) - :doc:`Session Library ` unnecessarily stripped slashed from serialized data, making it impossible to read objects in a namespace. +- Fixed a bug (#658) - :doc:`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 ` +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: -- cgit v1.2.3-24-g4f1b From 7330384763d39d4b6066e036def51996a82103b4 Mon Sep 17 00:00:00 2001 From: GDmac Date: Tue, 30 Oct 2012 13:05:05 +0100 Subject: Description for Fix #1938 added to changelog Signed-off-by: GDmac --- user_guide_src/source/changelog.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 5b3ca3e9f..065daf54b 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -400,6 +400,7 @@ Bug fixes for 3.0 - Fixed a bug (#142) - :doc:`Form Helper ` function ``form_dropdown()`` didn't escape HTML entities in option values. - Fixed a bug (#50) - :doc:`Session Library ` unnecessarily stripped slashed from serialized data, making it impossible to read objects in a namespace. - Fixed a bug (#658) - :doc:`Routing ` wildcard **:any** didn't work as advertised and matched multiple URI segments instead of all characters within a single segment. +- Fixed a bug (#1938) - :doc:`Email ` where the email library removed multiple spaces inside a pre-formatted plain text message. Version 2.1.3 ============= -- cgit v1.2.3-24-g4f1b