This commit is contained in:
@@ -10,6 +10,11 @@ $Source$
|
||||
conversion.
|
||||
* libraries/dbi/mysql.dbi.lib.php, libraries/dbi/mysqli.dbi.lib.php: Fix
|
||||
PMA_mysql_fetch_array return value for last result (bug #905223).
|
||||
* browse_foreigners.php, libraries/common.lib.php,
|
||||
libraries/display_tbl.lib.php, libraries/relation.lib.php,
|
||||
libraries/sqlparser.lib.php, libraries/string.lib.php,
|
||||
libraries/transformations/text_plain__substr.inc.php: Use charset aware
|
||||
substr and strlen functions (bugs #854755 and #910575).
|
||||
|
||||
2004-03-05 Marc Delisle <lem9@users.sourceforge.net>
|
||||
* libraries/sqlparser.lib.php: bug 909752, floating point digit
|
||||
|
@@ -186,7 +186,7 @@ if (isset($disp_row) && is_array($disp_row)) {
|
||||
$vtitle = '';
|
||||
} else {
|
||||
$vtitle = htmlspecialchars($val);
|
||||
$value = htmlspecialchars(substr($val, 0, $cfg['LimitChars']) . '...');
|
||||
$value = htmlspecialchars(PMA_substr($val, 0, $cfg['LimitChars']) . '...');
|
||||
}
|
||||
|
||||
$key_equals_data = isset($data) && $key == $data;
|
||||
|
@@ -251,9 +251,7 @@ if ($is_minimum_common == FALSE) {
|
||||
* Charset conversion.
|
||||
*/
|
||||
require_once('./libraries/charset_conversion.lib.php');
|
||||
}
|
||||
|
||||
if ($is_minimum_common == FALSE) {
|
||||
/**
|
||||
* String handling
|
||||
*/
|
||||
|
@@ -1362,8 +1362,8 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql)
|
||||
$vertical_display['data'][$row_no][$i] = ' <td valign="top" ' . $column_style . ' bgcolor="' . $bgcolor . '"><i>NULL</i></td>' . "\n";
|
||||
} else if ($row[$pointer] != '') {
|
||||
// garvin: if a transform function for blob is set, none of these replacements will be made
|
||||
if (strlen($row[$pointer]) > $GLOBALS['cfg']['LimitChars'] && ($dontlimitchars != 1)) {
|
||||
$row[$pointer] = substr($row[$pointer], 0, $GLOBALS['cfg']['LimitChars']) . '...';
|
||||
if (PMA_strlen($row[$pointer]) > $GLOBALS['cfg']['LimitChars'] && ($dontlimitchars != 1)) {
|
||||
$row[$pointer] = PMA_substr($row[$pointer], 0, $GLOBALS['cfg']['LimitChars']) . '...';
|
||||
}
|
||||
// loic1: displays all space characters, 4 space
|
||||
// characters for tabulations and <cr>/<lf>
|
||||
@@ -1384,8 +1384,8 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql)
|
||||
$relation_id = $row[$pointer];
|
||||
|
||||
// nijel: Cut all fields to $cfg['LimitChars']
|
||||
if (strlen($row[$pointer]) > $GLOBALS['cfg']['LimitChars'] && ($dontlimitchars != 1)) {
|
||||
$row[$pointer] = substr($row[$pointer], 0, $GLOBALS['cfg']['LimitChars']) . '...';
|
||||
if (PMA_strlen($row[$pointer]) > $GLOBALS['cfg']['LimitChars'] && ($dontlimitchars != 1)) {
|
||||
$row[$pointer] = PMA_substr($row[$pointer], 0, $GLOBALS['cfg']['LimitChars']) . '...';
|
||||
}
|
||||
|
||||
// loic1: displays special characters from binaries
|
||||
|
@@ -604,7 +604,7 @@ function PMA_foreignDropdown($disp, $foreign_field, $foreign_display, $data, $ma
|
||||
|
||||
foreach($disp AS $disp_key => $relrow) {
|
||||
$key = $relrow[$foreign_field];
|
||||
if (strlen($relrow[$foreign_display]) <= $cfg['LimitChars']) {
|
||||
if (PMA_strlen($relrow[$foreign_display]) <= $cfg['LimitChars']) {
|
||||
$value = (($foreign_display != FALSE) ? htmlspecialchars($relrow[$foreign_display]) : '');
|
||||
$vtitle = '';
|
||||
} else {
|
||||
|
@@ -211,7 +211,7 @@ if ($is_minimum_common == FALSE) {
|
||||
$sql = str_replace("\r\n", "\n", $sql);
|
||||
$sql = str_replace("\r", "\n", $sql);
|
||||
|
||||
$len = $GLOBALS['PMA_strlen']($sql);
|
||||
$len = PMA_strlen($sql);
|
||||
if ($len == 0) {
|
||||
return array();
|
||||
}
|
||||
@@ -288,7 +288,7 @@ if ($is_minimum_common == FALSE) {
|
||||
break;
|
||||
} // end switch
|
||||
$count2 = ($pos < $count2) ? $len : $pos;
|
||||
$str = $GLOBALS['PMA_substr']($sql, $count1, $count2 - $count1);
|
||||
$str = PMA_substr($sql, $count1, $count2 - $count1);
|
||||
PMA_SQP_arrayAdd($sql_array, 'comment_' . $type, $str, $arraysize);
|
||||
continue;
|
||||
} // end if
|
||||
@@ -348,7 +348,7 @@ if ($is_minimum_common == FALSE) {
|
||||
default:
|
||||
break;
|
||||
} // end switch
|
||||
$data = $GLOBALS['PMA_substr']($sql, $count1, $count2 - $count1);
|
||||
$data = PMA_substr($sql, $count1, $count2 - $count1);
|
||||
PMA_SQP_arrayAdd($sql_array, $type, $data, $arraysize);
|
||||
continue;
|
||||
}
|
||||
@@ -387,7 +387,7 @@ if ($is_minimum_common == FALSE) {
|
||||
if ($l == 1) {
|
||||
$punct_data = $c;
|
||||
} else {
|
||||
$punct_data = $GLOBALS['PMA_substr']($sql, $count1, $l);
|
||||
$punct_data = PMA_substr($sql, $count1, $l);
|
||||
}
|
||||
|
||||
// Special case, sometimes, althought two characters are
|
||||
@@ -424,10 +424,10 @@ if ($is_minimum_common == FALSE) {
|
||||
$punct_data = $first;
|
||||
} else if (($last2 == '/*') || ($last2 == '--')) {
|
||||
$count2 -= 2;
|
||||
$punct_data = $GLOBALS['PMA_substr']($sql, $count1, $count2 - $count1);
|
||||
$punct_data = PMA_substr($sql, $count1, $count2 - $count1);
|
||||
} else if (($last == '-') || ($last == '+') || ($last == '!')) {
|
||||
$count2--;
|
||||
$punct_data = $GLOBALS['PMA_substr']($sql, $count1, $count2 - $count1);
|
||||
$punct_data = PMA_substr($sql, $count1, $count2 - $count1);
|
||||
// TODO: for negation operator, split in 2 tokens ?
|
||||
// "select x&~1 from t"
|
||||
// becomes "select x & ~ 1 from t" ?
|
||||
@@ -475,7 +475,7 @@ if ($is_minimum_common == FALSE) {
|
||||
continue;
|
||||
} else {
|
||||
$debugstr = $GLOBALS['strSQPBugInvalidIdentifer'] . ' @ ' . ($count1+1) . "\n"
|
||||
. 'STR: ' . $GLOBALS['PMA_substr']($sql, $count1, $count2 - $count1);
|
||||
. 'STR: ' . PMA_substr($sql, $count1, $count2 - $count1);
|
||||
PMA_SQP_throwError($debugstr, $sql);
|
||||
return $sql;
|
||||
}
|
||||
@@ -503,7 +503,7 @@ if ($is_minimum_common == FALSE) {
|
||||
} // end while
|
||||
|
||||
$l = $count2 - $count1;
|
||||
$str = $GLOBALS['PMA_substr']($sql, $count1, $l);
|
||||
$str = PMA_substr($sql, $count1, $l);
|
||||
|
||||
$type = '';
|
||||
if ($is_digit) {
|
||||
@@ -532,7 +532,7 @@ if ($is_minimum_common == FALSE) {
|
||||
$count2++;
|
||||
|
||||
$debugstr = 'C1 C2 LEN: ' . $count1 . ' ' . $count2 . ' ' . $len . "\n"
|
||||
. 'STR: ' . $GLOBALS['PMA_substr']($sql, $count1, $count2 - $count1) . "\n";
|
||||
. 'STR: ' . PMA_substr($sql, $count1, $count2 - $count1) . "\n";
|
||||
PMA_SQP_bug($debugstr, $sql);
|
||||
return $sql;
|
||||
|
||||
@@ -1567,7 +1567,7 @@ if ($is_minimum_common == FALSE) {
|
||||
$i = $GLOBALS['PMA_strpos']($arr['type'], '_');
|
||||
$class = '';
|
||||
if ($i > 0) {
|
||||
$class = 'syntax_' . $GLOBALS['PMA_substr']($arr['type'], 0, $i) . ' ';
|
||||
$class = 'syntax_' . PMA_substr($arr['type'], 0, $i) . ' ';
|
||||
}
|
||||
|
||||
$class .= 'syntax_' . $arr['type'];
|
||||
|
@@ -15,18 +15,61 @@
|
||||
* The SQL Parser code relies heavily on these functions.
|
||||
*/
|
||||
|
||||
|
||||
// This is for handling input better
|
||||
if (defined('PMA_MULTIBYTE_ENCODING')) {
|
||||
$GLOBALS['PMA_strlen'] = 'mb_strlen';
|
||||
$GLOBALS['PMA_strpos'] = 'mb_strpos';
|
||||
$GLOBALS['PMA_strrpos'] = 'mb_strrpos';
|
||||
$GLOBALS['PMA_substr'] = 'mb_substr';
|
||||
} else {
|
||||
$GLOBALS['PMA_strlen'] = 'strlen';
|
||||
$GLOBALS['PMA_strpos'] = 'strpos';
|
||||
$GLOBALS['PMA_strrpos'] = 'strrpos';
|
||||
$GLOBALS['PMA_substr'] = 'substr';
|
||||
}
|
||||
|
||||
$GLOBALS['PMA_has_mbstr'] = @function_exists('mb_strlen');
|
||||
|
||||
/**
|
||||
* Returns length of string depending on current charset.
|
||||
*
|
||||
* @param string string to count
|
||||
*
|
||||
* @return int string length
|
||||
*
|
||||
* @access public
|
||||
*
|
||||
* @author nijel
|
||||
*/
|
||||
function PMA_strlen($string)
|
||||
{
|
||||
if (defined('PMA_MULTIBYTE_ENCODING')) {
|
||||
return mb_strlen($string);
|
||||
} elseif($GLOBALS['PMA_has_mbstr']) {
|
||||
return mb_strlen($string, $GLOBALS['charset']);
|
||||
} else {
|
||||
return strlen($string);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns substring from string, works depending on current charset.
|
||||
*
|
||||
* @param string string to count
|
||||
* @param int start of substring
|
||||
* @param int length of substring
|
||||
*
|
||||
* @return int string length
|
||||
*
|
||||
* @access public
|
||||
*
|
||||
* @author nijel
|
||||
*/
|
||||
function PMA_substr($string, $start, $length = 2147483647)
|
||||
{
|
||||
if (defined('PMA_MULTIBYTE_ENCODING')) {
|
||||
return mb_substr($string, $start, $length);
|
||||
} elseif($GLOBALS['PMA_has_mbstr']) {
|
||||
return mb_substr($string, $start, $length, $GLOBALS['charset']);
|
||||
} else {
|
||||
return substr($string, $start, $length);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@@ -21,9 +21,9 @@ function PMA_transformation_text_plain__substr($buffer, $options = array(), $met
|
||||
|
||||
$newtext = '';
|
||||
if ($options[1] != 'all') {
|
||||
$newtext = substr($buffer, $options[0], $options[1]);
|
||||
$newtext = PMA_substr($buffer, $options[0], $options[1]);
|
||||
} else {
|
||||
$newtext = substr($buffer, $options[0]);
|
||||
$newtext = PMA_substr($buffer, $options[0]);
|
||||
}
|
||||
|
||||
$length = strlen($newtext);
|
||||
|
Reference in New Issue
Block a user