Merge branch 'develop' into feature/form_validation/custom_error_per_field
diff --git a/application/config/user_agents.php b/application/config/user_agents.php
index e555d77..2af70bf 100644
--- a/application/config/user_agents.php
+++ b/application/config/user_agents.php
@@ -85,6 +85,8 @@
 	'OPR'			=> 'Opera',
 	'Flock'			=> 'Flock',
 	'Chrome'		=> 'Chrome',
+	// Opera 10+ always reports Opera/9.80 and appends Version/<real version> to the user agent string
+	'Opera.*?Version'	=> 'Opera',
 	'Opera'			=> 'Opera',
 	'MSIE'			=> 'Internet Explorer',
 	'Internet Explorer'	=> 'Internet Explorer',
diff --git a/system/helpers/url_helper.php b/system/helpers/url_helper.php
index 2d92897..f819b96 100644
--- a/system/helpers/url_helper.php
+++ b/system/helpers/url_helper.php
@@ -91,7 +91,8 @@
 	 */
 	function current_url()
 	{
-		return get_instance()->config->site_url($CI->uri->uri_string());
+		$CI =& get_instance();
+		return $CI->config->site_url($CI->uri->uri_string());
 	}
 }
 
diff --git a/system/libraries/Session/drivers/Session_cookie.php b/system/libraries/Session/drivers/Session_cookie.php
index 65debcb..971dfea 100644
--- a/system/libraries/Session/drivers/Session_cookie.php
+++ b/system/libraries/Session/drivers/Session_cookie.php
@@ -223,7 +223,7 @@
 			'encryption_key',
 		);
 
-		$this->_standardize_newlines = (bool) $config['standardize_newlines'];
+		$this->_standardize_newlines = (bool) config_item('standardize_newlines');
 
 		foreach ($prefs as $key)
 		{
diff --git a/system/libraries/User_agent.php b/system/libraries/User_agent.php
index 50ac9be..3a6b6bc 100644
--- a/system/libraries/User_agent.php
+++ b/system/libraries/User_agent.php
@@ -282,7 +282,7 @@
 		{
 			foreach ($this->browsers as $key => $val)
 			{
-				if (preg_match('|'.preg_quote($key).'.*?([0-9\.]+)|i', $this->agent, $match))
+				if (preg_match('|'.$key.'.*?([0-9\.]+)|i', $this->agent, $match))
 				{
 					$this->is_browser = TRUE;
 					$this->version = $match[1];
@@ -634,6 +634,34 @@
 		return in_array(strtolower($charset), $this->charsets(), TRUE);
 	}
 
+	// --------------------------------------------------------------------
+
+	/**
+	 * Parse a custom user-agent string
+	 *
+	 * @param	string	$string
+	 * @return	void
+	 */
+	public function parse($string)
+	{
+		// Reset values
+		$this->is_browser = FALSE;
+		$this->is_robot = FALSE;
+		$this->is_mobile = FALSE;
+		$this->browser = '';
+		$this->version = '';
+		$this->mobile = '';
+		$this->robot = '';
+
+		// Set the new user-agent string and parse it, unless empty
+		$this->agent = $string;
+
+		if ( ! empty($string))
+		{
+			$this->_compile_data();
+		}
+	}
+
 }
 
 /* End of file User_agent.php */
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index 37e568c..314ae8a 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -370,7 +370,11 @@
       -  Added the ability to use a proxy.
       -  Added Basic HTTP authentication support.
 
-   -  :doc:`User Agent Library <libraries/user_agent>` will now check if robots are pretending to be mobile clients (helps with e.g. Google indexing mobile website versions).
+   -  :doc:`User Agent Library <libraries/user_agent>` changes include:
+
+      - Added check to detect if robots are pretending to be mobile clients (helps with e.g. Google indexing mobile website versions).
+      - Added method ``parse()`` to allow parsing a custom user-agent string, different from the current visitor's.
+
    -  Added support for setting :doc:`Table <libraries/table>` class defaults in a config file.
    -  :doc:`Zip Library <libraries/zip>` method ``read_file()`` can now also alter the original file path/name while adding files to an archive.
 
@@ -652,6 +656,7 @@
 -  Fixed a bug (#2762) - :doc:`Hooks Class <general/hooks>` didn't properly check if the called class/function exists.
 -  Fixed a bug (#148) - while sanitizing input data, ``CI_Input::_clean_input_data()`` assumed that it is URL-encoded, stripping certain character sequences from it.
 -  Fixed a bug (#346) - with ``$config['global_xss_filtering']`` turned on, the ``$_GET``, ``$_POST``, ``$_COOKIE`` and ``$_SERVER`` superglobals were overwritten during initialization time, resulting in XSS filtering being either performed twice or there was no possible way to get the original data, even though options for this do exist.
+-  Fixed an edge case (#555) - incorrect browser version was reported for Opera 10+ due to a non-standard user-agent string.
 
 Version 2.1.4
 =============