Project

General

Profile

Actions

Bug #15441

closed

strtoupper() broken some text in non-ascii

Added by old_hkdennis2k over 18 years ago. Updated over 11 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
-
Target version:
-
Start date:
2006-01-18
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
4.3
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

In Backend some where are using strtoupper to display a bolded title.

e.g. class.tx_cms_layout.php
function tt_content_drawColHeader($colName,$editParams,$newParams){
$out ='.............<b>'.htmlspecialchars(strtoupper($colName)).'</b>...........';
}

but, strtoupper() may destory the text since it may be multi-byte or non-ascii.

Suggestion replacement:
We don't have to consider any function exists in the server.
Using CSS to display text in uppercase. Server should not change on the text.

e.g.
$out='<b style="text-transform:uppercase">'.htmlspecialchars($colName).'</b>

(issue imported from #M2302)


Files

strtoupper_list.txt (67.9 KB) strtoupper_list.txt Administrator Admin, 2008-06-27 10:36
2302.diff (231 KB) 2302.diff Administrator Admin, 2008-06-27 11:50
Actions #1

Updated by Martin Kutschker over 18 years ago

Suggested solution: use case shifting functions from t3lib_cs.

Suggestion for a better bug report: list all files (and lines) with the found problem. If you find more than one location it's disappointing to see only a "e.g."..

Actions #2

Updated by old_hkdennis2k over 18 years ago

Why you want to handle it and waste processing power in serverside when clientside can handle it very well??

I will only use that function for non-HTML output.

I agree, I am too lazy.

Most of the mod using strtoupper to display a BOLD header.
But, all of them are not i18n yet. The text are hard coded in php. I think it is another bug, I don't list them here.

After my search, class.tx_cms_layout.php should be the only mod do strtoupper() on a text extract from locallang.

typo3/sysext/cms/layout/class.tx_cms_layout.php
1441: <td class="bgColor2" nowrap="nowrap"><img src="clear.gif" width="1" height="2" alt="" /><br /><div align="center"><b>'.htmlspecialchars(strtoupper($colName)).'</b></div><img src="clear.gif" width="1" height="2" alt="" /></td>

t3lib/class.t3lib_befunc.php
2026: if ($config) $lines[$fname].='<strong>'.strtoupper(htmlspecialchars($config)).'</strong><br />';

t3lib\class.t3lib_formmail.php
123: $Plain_content.= strtoupper($key).': '.$space.$val."\n".$space;

t3lib\class.t3lib_tcemain.php
1959:
case 'upper':
$value = strtoupper($value);
  1. $value = strtr($value, '���������������', '���������������'); // WILL make trouble with other charsets than ISO-8859-1, so what do we do here? PHP-function which can handle this for other charsets? Currently the browsers JavaScript will fix it.
    break;
    case 'lower':
    $value = strtolower($value);
  2. $value = strtr($value, '���������������', '���������������'); // WILL make trouble with other charsets than ISO-8859-1, so what do we do here? PHP-function which can handle this for other charsets? Currently the browsers JavaScript will fix it.
    break;

EXT:sr_static_info/pi1/class.tx_srstaticinfo_pi1.php
582: $formatedAddress = str_replace('%countryName', strtoupper($countryName), $formatedAddress);

EXT:tt_board/pi/board_submit.inc
122: $markersArray["###SUBJECT###"] = strtoupper($this->newData["tt_board"]["NEW"][subject]);

Actions #3

Updated by Karsten Dambekalns over 18 years ago

I like the idea of using CSS for this, but please not
<b style="text-transform:uppercase">
but rather
<span style="font-weight:bold; text-transform:uppercase;">

Actions #4

Updated by Benni Mack almost 16 years ago

isn't that related to the turkish strtoupper problem?

Then the first step would be to search and replace all strtoupper() functions with the TYPO3-own function for uppercasing.

Second would be the semantic approach to look for places where strtouppper is used wrongly.

Actions #5

Updated by Steffen Kamper almost 16 years ago

use t3lib_div::strtoupper for safe conversion.
Also look for
strtolower => t3lib_div::strtolower

Actions #6

Updated by Benni Mack almost 16 years ago

Hey,

I attached a list of all places where strotupper / lower is used. If anyone wants to go through all places and see where it needs to change, go for it.

Actions #7

Updated by Steffen Kamper almost 16 years ago

ok, i do

Actions #8

Updated by Steffen Kamper almost 16 years ago

i uploaded the patch - heavy stuff :-)

Actions #9

Updated by Dmitry Dulepov almost 16 years ago

Blindly replacing every occurence of strtolower or strtoupper is bad. There are cases when it is not needed. For example:

if (strtolower($str) === 'true') {

In this case there is no need for t3lib_div method. If strtolower fails we know it does not contain TRUE, true tRuE or any other combination.

-1 for the current solution as it is inefective.

Actions #10

Updated by Benni Mack almost 16 years ago

Hey Dmitry,

in such cases, wouldn't it make sense to do a "stricmp($str, 'true') == 0" ?

Actions #11

Updated by Georg Ringer almost 13 years ago

  • Target version deleted (0)
  • TYPO3 Version changed from 3.8.1 to 4.3
  • PHP Version deleted (5)

IMO strtoupper is at least now binary save, possible to close that?

Actions #12

Updated by Helmut Hummel over 12 years ago

  • Status changed from Accepted to Needs Feedback

Still a problem? I've never run into that.

Actions #13

Updated by Xavier Perseguers about 12 years ago

  • Assignee deleted (Steffen Kamper)
Actions #14

Updated by Jigal van Hemert over 11 years ago

  • Status changed from Needs Feedback to Closed

No feedback for over 90 days, strtoupper() is now binary-safe and we used UTF-8 inside the core and in the backend. Closed.

Actions

Also available in: Atom PDF