summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Andreev <narf@devilix.net>2017-10-16 10:11:00 +0200
committerAndrey Andreev <narf@devilix.net>2017-10-16 10:11:00 +0200
commit7907f98a963c0cb8625ecbb4d8a178c6d769339a (patch)
tree0ae85eb89a0d774d36eaf0ddba9509cdced973d8
parent61dfda5953f99813f8309a4fa843c255b6631224 (diff)
parentd282d07dfba94b5395d1dd989bdb958c972bb7cf (diff)
Merge branch '3.1-stable' into develop
-rw-r--r--system/database/DB_driver.php12
-rw-r--r--system/database/DB_query_builder.php2
-rw-r--r--system/database/drivers/mysqli/mysqli_result.php14
-rw-r--r--system/database/drivers/mysqli/mysqli_utility.php6
-rw-r--r--system/libraries/Email.php4
-rw-r--r--system/libraries/Form_validation.php2
-rw-r--r--tests/codeigniter/helpers/url_helper_test.php3
-rw-r--r--user_guide_src/source/changelog.rst13
-rw-r--r--user_guide_src/source/libraries/pagination.rst4
9 files changed, 33 insertions, 27 deletions
diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php
index 54740c309..8ab5d762e 100644
--- a/system/database/DB_driver.php
+++ b/system/database/DB_driver.php
@@ -1867,15 +1867,19 @@ abstract class CI_DB_driver {
$i++;
}
+ // dbprefix may've already been applied, with or without the identifier escaped
+ $ec = '(?<ec>'.preg_quote(is_array($this->_escape_char) ? $this->_escape_char[0] : $this->_escape_char).')?';
+ isset($ec[0]) && $ec .= '?'; // Just in case someone has disabled escaping by forcing an empty escape character
+
// Verify table prefix and replace if necessary
- if ($this->swap_pre !== '' && strpos($parts[$i], $this->swap_pre) === 0)
+ if ($this->swap_pre !== '' && preg_match('#^'.$ec.preg_quote($this->swap_pre).'#', $parts[$i]))
{
- $parts[$i] = preg_replace('/^'.$this->swap_pre.'(\S+?)/', $this->dbprefix.'\\1', $parts[$i]);
+ $parts[$i] = preg_replace('#^'.$ec.preg_quote($this->swap_pre).'(\S+?)#', '\\1'.$this->dbprefix.'\\2', $parts[$i]);
}
// We only add the table prefix if it does not already exist
- elseif (strpos($parts[$i], $this->dbprefix) !== 0)
+ else
{
- $parts[$i] = $this->dbprefix.$parts[$i];
+ preg_match('#^'.$ec.preg_quote($this->dbprefix).'#', $parts[$i]) OR $parts[$i] = $this->dbprefix.$parts[$i];
}
// Put the parts back together
diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php
index e7b66ac80..baa5ba814 100644
--- a/system/database/DB_query_builder.php
+++ b/system/database/DB_query_builder.php
@@ -1477,7 +1477,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
// for selecting COUNT(*) ...
$qb_orderby = $this->qb_orderby;
$qb_cache_orderby = $this->qb_cache_orderby;
- $this->qb_orderby = $this->qb_cache_orderby = NULL;
+ $this->qb_orderby = $this->qb_cache_orderby = array();
$result = ($this->qb_distinct === TRUE OR ! empty($this->qb_groupby) OR ! empty($this->qb_cache_groupby) OR $this->qb_limit OR $this->qb_offset)
? $this->query($this->_count_string.$this->protect_identifiers('numrows')."\nFROM (\n".$this->_compile_select()."\n) CI_count_all_results")
diff --git a/system/database/drivers/mysqli/mysqli_result.php b/system/database/drivers/mysqli/mysqli_result.php
index 0b3d9c2b4..bd465c405 100644
--- a/system/database/drivers/mysqli/mysqli_result.php
+++ b/system/database/drivers/mysqli/mysqli_result.php
@@ -130,10 +130,10 @@ class CI_DB_mysqli_result extends CI_DB_result {
* mysqli_result::fetch_fields()
*
* @used-by CI_DB_mysqli_result::field_data()
- * @param int $flags
+ * @param int $type
* @return string
*/
- private static function _get_field_type($flags)
+ private static function _get_field_type($type)
{
static $map;
isset($map) OR $map = array(
@@ -164,15 +164,7 @@ class CI_DB_mysqli_result extends CI_DB_result {
MYSQLI_TYPE_GEOMETRY => 'geometry'
);
- foreach ($map as $flag => $name)
- {
- if ($flags & $flag)
- {
- return $name;
- }
- }
-
- return $flags;
+ return isset($map[$type]) ? $map[$type] : $type;
}
// --------------------------------------------------------------------
diff --git a/system/database/drivers/mysqli/mysqli_utility.php b/system/database/drivers/mysqli/mysqli_utility.php
index 1699b611f..82cf5cebf 100644
--- a/system/database/drivers/mysqli/mysqli_utility.php
+++ b/system/database/drivers/mysqli/mysqli_utility.php
@@ -155,11 +155,7 @@ class CI_DB_mysqli_utility extends CI_DB_utility {
while ($field = $query->result_id->fetch_field())
{
// Most versions of MySQL store timestamp as a string
- $is_int[$i] = ($field->type & MYSQLI_TYPE_TINY)
- OR ($field->type & MYSQLI_TYPE_SHORT)
- OR ($field->type & MYSQLI_TYPE_INT24)
- OR ($field->type & MYSQLI_TYPE_LONG)
- OR ($field->type & MYSQLI_TYPE_LONGLONG);
+ $is_int[$i] = in_array($field->type, array(MYSQLI_TYPE_TINY, MYSQLI_TYPE_SHORT, MYSQLI_TYPE_INT24, MYSQLI_TYPE_LONG), TRUE);
// Create a string of field names
$field_str .= $this->db->escape_identifiers($field->name).', ';
diff --git a/system/libraries/Email.php b/system/libraries/Email.php
index 1dcafeddd..5943127bc 100644
--- a/system/libraries/Email.php
+++ b/system/libraries/Email.php
@@ -1016,7 +1016,7 @@ class CI_Email {
{
if (function_exists('idn_to_ascii') && $atpos = strpos($email, '@'))
{
- $email = self::substr($email, 0, ++$atpos).idn_to_ascii(self::substr($email, $atpos));
+ $email = self::substr($email, 0, ++$atpos).idn_to_ascii(self::substr($email, $atpos), INTL_IDNA_VARIANT_UTS46);
}
return (bool) filter_var($email, FILTER_VALIDATE_EMAIL);
@@ -1823,7 +1823,7 @@ class CI_Email {
{
if (function_exists('idn_to_ascii') && $atpos = strpos($email, '@'))
{
- $email = self::substr($email, 0, ++$atpos).idn_to_ascii(self::substr($email, $atpos));
+ $email = self::substr($email, 0, ++$atpos).idn_to_ascii(self::substr($email, $atpos), INTL_IDNA_VARIANT_UTS46);
}
return (filter_var($email, FILTER_VALIDATE_EMAIL) === $email && preg_match('#\A[a-z0-9._+-]+@[a-z0-9.-]{1,253}\z#i', $email));
diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php
index 0dfb274b2..ee9ea6850 100644
--- a/system/libraries/Form_validation.php
+++ b/system/libraries/Form_validation.php
@@ -1237,7 +1237,7 @@ class CI_Form_validation {
{
if (function_exists('idn_to_ascii') && preg_match('#\A([^@]+)@(.+)\z#', $str, $matches))
{
- $str = $matches[1].'@'.idn_to_ascii($matches[2]);
+ $str = $matches[1].'@'.idn_to_ascii($matches[2], INTL_IDNA_VARIANT_UTS46);
}
return (bool) filter_var($str, FILTER_VALIDATE_EMAIL);
diff --git a/tests/codeigniter/helpers/url_helper_test.php b/tests/codeigniter/helpers/url_helper_test.php
index c5b0f80b7..f33189a3a 100644
--- a/tests/codeigniter/helpers/url_helper_test.php
+++ b/tests/codeigniter/helpers/url_helper_test.php
@@ -63,7 +63,8 @@ class Url_helper_test extends CI_TestCase {
'<br />www.google.com' => '<br /><a href="http://www.google.com">www.google.com</a>',
'Download CodeIgniter at www.codeigniter.com. Period test.' => 'Download CodeIgniter at <a href="http://www.codeigniter.com">www.codeigniter.com</a>. Period test.',
'Download CodeIgniter at www.codeigniter.com, comma test' => 'Download CodeIgniter at <a href="http://www.codeigniter.com">www.codeigniter.com</a>, comma test',
- 'This one: ://codeigniter.com must not break this one: http://codeigniter.com' => 'This one: <a href="://codeigniter.com">://codeigniter.com</a> must not break this one: <a href="http://codeigniter.com">http://codeigniter.com</a>'
+ 'This one: ://codeigniter.com must not break this one: http://codeigniter.com' => 'This one: <a href="://codeigniter.com">://codeigniter.com</a> must not break this one: <a href="http://codeigniter.com">http://codeigniter.com</a>',
+ 'Trailing slash: https://codeigniter.com/ fubar' => 'Trailing slash: <a href="https://codeigniter.com/">https://codeigniter.com/</a> fubar'
);
foreach ($strings as $in => $out)
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index a1321fe94..0a625d861 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -119,6 +119,19 @@ Version 3.1.7
Release Date: Not Released
+- General Changes
+
+ - Updated :doc:`Form Validation Library <libraries/form_validation>` rule ``valid_email`` to use ``INTL_IDNA_VARIANT_UCS46`` for non-ASCII domain names.
+ - Updated :doc:`Email Library <libraries/email>` to use ``INTL_IDNA_VARIANT_UCS46`` for non-ASCII domain names.
+
+Bug fixes for 3.1.7
+-------------------
+
+- Fixed a regression (#5276) - :doc:`Database Utilities <database/utilities>` method ``backup()`` generated incorrect ``INSERT`` statements with the 'mysqli' driver.
+- Fixed a regression where :doc:`Database Results <database/results>` method ``field_data()`` returned incorrect type names.
+- Fixed a bug (#5278) - :doc:`URL Helper <helpers/url_helper>` function :php:func:`auto_link()` didn't detect trailing slashes in URLs.
+- Fixed a regression (#5282) - :doc:`Query Builder <database/query_builder>` method ``count_all_results()`` breaks ``ORDER BY`` clauses for subsequent queries.
+- Fixed a bug (#5279) - :doc:`Query Builder <database/query_builder>` didn't account for already escaped identifiers while applying database name prefixes.
Version 3.1.6
=============
diff --git a/user_guide_src/source/libraries/pagination.rst b/user_guide_src/source/libraries/pagination.rst
index 99b5a80a2..fbc75ea56 100644
--- a/user_guide_src/source/libraries/pagination.rst
+++ b/user_guide_src/source/libraries/pagination.rst
@@ -128,7 +128,7 @@ the offset segment.
**$config['suffix'] = '';**
-A custom suffix added to the path. The sufix value will be right after
+A custom suffix added to the path. The suffix value will be right after
the offset segment.
**$config['use_global_url_suffix'] = FALSE;**
@@ -311,4 +311,4 @@ Class Reference
:returns: HTML-formatted pagination
:rtype: string
- Returns a "pagination" bar, containing the generated links or an empty string if there's just a single page. \ No newline at end of file
+ Returns a "pagination" bar, containing the generated links or an empty string if there's just a single page.