Bug #15441
closedstrtoupper() broken some text in non-ascii
0%
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
Updated by Martin Kutschker almost 19 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."..
Updated by old_hkdennis2k almost 19 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;
1959:
case 'upper':
$value = strtoupper($value);
- $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); - $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]);
Updated by Karsten Dambekalns almost 19 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;">
Updated by Benni Mack over 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.
Updated by Steffen Kamper over 16 years ago
use t3lib_div::strtoupper for safe conversion.
Also look for
strtolower => t3lib_div::strtolower
Updated by Benni Mack over 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.
Updated by Steffen Kamper over 16 years ago
i uploaded the patch - heavy stuff :-)
Updated by Dmitry Dulepov over 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.
Updated by Benni Mack over 16 years ago
Hey Dmitry,
in such cases, wouldn't it make sense to do a "stricmp($str, 'true') == 0" ?
Updated by Georg Ringer over 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?
Updated by Helmut Hummel about 13 years ago
- Status changed from Accepted to Needs Feedback
Still a problem? I've never run into that.
Updated by Xavier Perseguers almost 13 years ago
- Assignee deleted (
Steffen Kamper)
Updated by Jigal van Hemert almost 12 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.