Bug #14977
closedFunction 'getBorderAttr' for removing 'border="0"' from img-tags doesn't work
0%
Description
By validating my website I found out, that typo3 automatically renders the parameter 'border="0"' into img-tags. On my search to remove those, I found the function 'getBorderAttr' which should remove those attributes if a special doctype is set, or if the variable 'disableImgBorderAttr' is set. But the function has a logical error in the if-clause, so that the parameter only gets removed when both clauses are true insted of one of them.
BUG:
function: 'getBorderAttr'
file: 'class.tslib_content.php'
lines: 2511-2521
wrong (line 2518):
--------
if (t3lib_div::inList('xhtml_strict,xhtml_11,xhtml_2',$GLOBALS['TSFE']->config['config']['doctype']) || $GLOBALS['TSFE']->config['config']['disableImgBorderAttr']) {
--------
correct:
--------
if (t3lib_div::inList('xhtml_strict,xhtml_11,xhtml_2',$GLOBALS['TSFE']->config['config']['doctype']) && !$GLOBALS['TSFE']->config['config']['disableImgBorderAttr']) {
--------
Here the complete working function:
----------------------
/**
* Returns the 'border' attribute for an <img> tag only if the doctype is not xhtml_strict,xhtml_11 or xhtml_2 or if the config parameter 'disableImgBorderAttr' is not set.
*
* @param string the border attribute
* @return string the border attribute
*/
function getBorderAttr($borderAttr) {
if (t3lib_div::inList('xhtml_strict,xhtml_11,xhtml_2',$GLOBALS['TSFE']->config['config']['doctype']) && !$GLOBALS['TSFE']->config['config']['disableImgBorderAttr']) {
return $borderAttr;
}
}
(issue imported from #M1461)
Files
Updated by Rupert Germann over 18 years ago
hi Franz,
What you suggest will not work as it was intended. With your change the border attrib is only rendered if the doctype AND "disableImgBorderAttr" are both not matching.
The attached patch does it with an OR operation so the border is not rendered if the doctype is among the listed doctypes OR "disableImgBorderAttr" is set.
Updated by Franz Koch over 18 years ago
Hi Rupert,
ups, my fault - don't ask what donkey I'd been riding. Anyway there was a bug :) Thanks for fixing.
Updated by Ernesto Baschny over 18 years ago
As far as I can see:
Koch's patch does !a && !b.
Rupi's patch does !(a || b).
Acording to DeMorgan's law, both should provide the same output. :)
Btw, I already provided this patch (Koch's version) some months ago, see http://bugs.typo3.org/view.php?id=1360
Updated by Franz Koch over 18 years ago
sorry again - now for the duplicate - but I really searched for it. Maybe I should sleep more...
PS: call me Franz :)