Commit af0463c6 authored by Dries's avatar Dries
Browse files

- Patch #279516 by c960657: remove workarounds for PHP versions less than 5.2.x

parent f9fd9c3b
...@@ -815,14 +815,8 @@ function check_plain($text) { ...@@ -815,14 +815,8 @@ function check_plain($text) {
* is outside of a tag, and thus deemed safe by a filter, can be interpreted * is outside of a tag, and thus deemed safe by a filter, can be interpreted
* by the browser as if it were inside the tag. * by the browser as if it were inside the tag.
* *
* This function exploits preg_match behaviour (since PHP 4.3.5) when used * The function does not return FALSE for strings containing character codes
* with the u modifier, as a fast way to find invalid UTF-8. When the matched * above U+10FFFF, even though these are prohibited by RFC 3629.
* string contains an invalid byte sequence, it will fail silently.
*
* preg_match may not fail on 4 and 5 octet sequences, even though they
* are not supported by the specification.
*
* The specific preg_match behaviour is present since PHP 4.3.5.
* *
* @param $text * @param $text
* The text to check. * The text to check.
...@@ -833,6 +827,9 @@ function drupal_validate_utf8($text) { ...@@ -833,6 +827,9 @@ function drupal_validate_utf8($text) {
if (strlen($text) == 0) { if (strlen($text) == 0) {
return TRUE; return TRUE;
} }
// With the PCRE_UTF8 modifier 'u', preg_match() fails silently on strings
// containing invalid UTF-8 byte sequences. It does not reject character
// codes above U+10FFFF (represented by 4 or more octets), though.
return (preg_match('/^./us', $text) == 1); return (preg_match('/^./us', $text) == 1);
} }
......
...@@ -451,7 +451,7 @@ function drupal_http_request($url, $headers = array(), $method = 'GET', $data = ...@@ -451,7 +451,7 @@ function drupal_http_request($url, $headers = array(), $method = 'GET', $data =
$fp = @fsockopen($uri['host'], $port, $errno, $errstr, 15); $fp = @fsockopen($uri['host'], $port, $errno, $errstr, 15);
break; break;
case 'https': case 'https':
// Note: Only works for PHP 4.3 compiled with OpenSSL. // Note: Only works when PHP is compiled with OpenSSL support.
$port = isset($uri['port']) ? $uri['port'] : 443; $port = isset($uri['port']) ? $uri['port'] : 443;
$host = $uri['host'] . ($port != 443 ? ':' . $port : ''); $host = $uri['host'] . ($port != 443 ? ':' . $port : '');
$fp = @fsockopen('ssl://' . $uri['host'], $port, $errno, $errstr, 20); $fp = @fsockopen('ssl://' . $uri['host'], $port, $errno, $errstr, 20);
......
...@@ -2211,12 +2211,8 @@ function db_rewrite_sql($query, $primary_table = 'n', $primary_field = 'nid', $ ...@@ -2211,12 +2211,8 @@ function db_rewrite_sql($query, $primary_table = 'n', $primary_field = 'nid', $
$n = strlen($matches[1]); $n = strlen($matches[1]);
$second_part = substr($query, $n); $second_part = substr($query, $n);
$first_part = substr($matches[1], 0, $n - 5) ." $join WHERE $where AND ( "; $first_part = substr($matches[1], 0, $n - 5) ." $join WHERE $where AND ( ";
// PHP 4 does not support strrpos for strings. We emulate it. foreach (array('GROUP', 'ORDER', 'LIMIT') as $needle) {
$haystack_reverse = strrev($second_part); $pos = strrpos($second_part, $needle);
// No need to use strrev on the needle, we supply GROUP, ORDER, LIMIT
// reversed.
foreach (array('PUORG', 'REDRO', 'TIMIL') as $needle_reverse) {
$pos = strpos($haystack_reverse, $needle_reverse);
if ($pos !== FALSE) { if ($pos !== FALSE) {
// All needles are five characters long. // All needles are five characters long.
$pos += 5; $pos += 5;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment