Commit 11a4aba9 authored by Steven Wittens's avatar Steven Wittens

- #26688: Add mbstring support to Drupal and clear up string handling fuzzies.

parent dd2c5765
......@@ -1831,7 +1831,7 @@ function drupal_implode_autocomplete($array) {
function _drupal_bootstrap_full() {
static $called;
global $locale;
global $locale, $multibyte;
if ($called) {
return;
......@@ -1849,6 +1849,8 @@ function _drupal_bootstrap_full() {
set_error_handler('error_handler');
// Emit the correct charset HTTP header.
drupal_set_header('Content-Type: text/html; charset=utf-8');
// Detect string handling method
$multibyte = unicode_check();
// Initialize $_GET['q'] prior to loading modules and invoking hook_init().
if (!empty($_GET['q'])) {
$_GET['q'] = drupal_get_normal_path(trim($_GET['q'], '/'));
......
This diff is collapsed.
......@@ -662,7 +662,7 @@ function book_render() {
*/
function book_export($type = 'html', $nid = 0) {
global $base_url;
$type = strtolower($type);
$type = drupal_strtolower($type);
$depth = _book_get_depth($nid);
switch ($type) {
case 'docbook':
......
......@@ -662,7 +662,7 @@ function book_render() {
*/
function book_export($type = 'html', $nid = 0) {
global $base_url;
$type = strtolower($type);
$type = drupal_strtolower($type);
$depth = _book_get_depth($nid);
switch ($type) {
case 'docbook':
......
......@@ -357,7 +357,7 @@ function search_index($sid, $type, $text) {
if ($tag) {
// Increase or decrease score per word based on tag
list($tagname) = explode(' ', $value, 2);
$tagname = strtolower($tagname);
$tagname = drupal_strtolower($tagname);
if ($tagname{0} == '/') {
$score -= $tags[substr($tagname, 1)];
if ($score < 1) { // possible due to bad HTML
......@@ -389,9 +389,8 @@ function search_index($sid, $type, $text) {
$words = search_keywords_split($value);
foreach ($words as $word) {
// Check wordlength
if (string_length($word) >= $minimum_word_size) {
// Note: strtolower can be used because the value is only used internally.
$word = strtolower($word);
if (drupal_strlen($word) >= $minimum_word_size) {
$word = drupal_strtolower($word);
if ($link) {
if (!isset($results[$linknid])) {
$results[$linknid] = array();
......@@ -484,13 +483,12 @@ function do_search($keywords, $type, $join = '', $where = '1', $variation = true
continue;
}
if (strpos($word, '�') !== false) {
// Note: strtolower can be used because the value is only used internally.
$words[] = "i.word LIKE '%s'";
$arguments[] = str_replace('�', '%', strtolower($word));
$arguments[] = str_replace('�', '%', drupal_strtolower($word));
}
else {
$words[] = "i.word = '%s'";
$arguments[] = strtolower($word);
$arguments[] = drupal_strtolower($word);
}
}
// Tell the user which words were excluded
......
......@@ -357,7 +357,7 @@ function search_index($sid, $type, $text) {
if ($tag) {
// Increase or decrease score per word based on tag
list($tagname) = explode(' ', $value, 2);
$tagname = strtolower($tagname);
$tagname = drupal_strtolower($tagname);
if ($tagname{0} == '/') {
$score -= $tags[substr($tagname, 1)];
if ($score < 1) { // possible due to bad HTML
......@@ -389,9 +389,8 @@ function search_index($sid, $type, $text) {
$words = search_keywords_split($value);
foreach ($words as $word) {
// Check wordlength
if (string_length($word) >= $minimum_word_size) {
// Note: strtolower can be used because the value is only used internally.
$word = strtolower($word);
if (drupal_strlen($word) >= $minimum_word_size) {
$word = drupal_strtolower($word);
if ($link) {
if (!isset($results[$linknid])) {
$results[$linknid] = array();
......@@ -484,13 +483,12 @@ function do_search($keywords, $type, $join = '', $where = '1', $variation = true
continue;
}
if (strpos($word, '�') !== false) {
// Note: strtolower can be used because the value is only used internally.
$words[] = "i.word LIKE '%s'";
$arguments[] = str_replace('�', '%', strtolower($word));
$arguments[] = str_replace('�', '%', drupal_strtolower($word));
}
else {
$words[] = "i.word = '%s'";
$arguments[] = strtolower($word);
$arguments[] = drupal_strtolower($word);
}
}
// Tell the user which words were excluded
......
......@@ -234,11 +234,11 @@ function system_view_general() {
$group = '';
$toolkits_available = image_get_available_toolkits();
if (count($toolkits_available) > 1) {
$group .= form_radios(t('Select an image processing toolkit'), 'image_toolkit', variable_get('image_toolkit', image_get_toolkit()), $toolkits_available);
$group .= form_radios(t('Select an image processing toolkit'), 'image_toolkit', variable_get('image_toolkit', image_get_toolkit()), $toolkits_available);
}
$group .= image_toolkit_invoke('settings');
if ($group) {
$output .= form_group_collapsible(t('Image handling'), '<p>'.$group.'</p>', TRUE);
$output .= form_group_collapsible(t('Image handling'), '<p>'. $group .'</p>', TRUE);
}
// Date settings:
......@@ -276,6 +276,9 @@ function system_view_general() {
$output .= form_group_collapsible(t('Date settings'), $group, TRUE);
// String handling: report status and errors.
$output .= form_group_collapsible(t('String handling'), unicode_settings(), TRUE);
return $output;
}
......@@ -678,7 +681,7 @@ function system_theme_settings($key = '') {
$rows = array();
// Use $utype field , and strtolower() it to get the type field.. to avoid issues with ucfirst() and unicode.
$type = strtolower($utype);
$type = drupal_strtolower($utype);
$value = $settings[$type . '_links'];
if (!is_array($value)) {
$value = array();
......
......@@ -234,11 +234,11 @@ function system_view_general() {
$group = '';
$toolkits_available = image_get_available_toolkits();
if (count($toolkits_available) > 1) {
$group .= form_radios(t('Select an image processing toolkit'), 'image_toolkit', variable_get('image_toolkit', image_get_toolkit()), $toolkits_available);
$group .= form_radios(t('Select an image processing toolkit'), 'image_toolkit', variable_get('image_toolkit', image_get_toolkit()), $toolkits_available);
}
$group .= image_toolkit_invoke('settings');
if ($group) {
$output .= form_group_collapsible(t('Image handling'), '<p>'.$group.'</p>', TRUE);
$output .= form_group_collapsible(t('Image handling'), '<p>'. $group .'</p>', TRUE);
}
// Date settings:
......@@ -276,6 +276,9 @@ function system_view_general() {
$output .= form_group_collapsible(t('Date settings'), $group, TRUE);
// String handling: report status and errors.
$output .= form_group_collapsible(t('String handling'), unicode_settings(), TRUE);
return $output;
}
......@@ -678,7 +681,7 @@ function system_theme_settings($key = '') {
$rows = array();
// Use $utype field , and strtolower() it to get the type field.. to avoid issues with ucfirst() and unicode.
$type = strtolower($utype);
$type = drupal_strtolower($utype);
$value = $settings[$type . '_links'];
if (!is_array($value)) {
$value = array();
......
......@@ -57,8 +57,8 @@ function user_load($array = array()) {
$params[] = $value;
}
else {
$query .= "LOWER(u.$key) = '%s' AND ";
$params[] = strtolower($value);
$query .= "LOWER(u.$key) = LOWER('%s') AND ";
$params[] = $value;
}
}
$result = db_query_range("SELECT u.* FROM {users} u WHERE $query u.status < 3", $params, 0, 1);
......
......@@ -57,8 +57,8 @@ function user_load($array = array()) {
$params[] = $value;
}
else {
$query .= "LOWER(u.$key) = '%s' AND ";
$params[] = strtolower($value);
$query .= "LOWER(u.$key) = LOWER('%s') AND ";
$params[] = $value;
}
}
$result = db_query_range("SELECT u.* FROM {users} u WHERE $query u.status < 3", $params, 0, 1);
......
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