PDA

View Full Version : [fixed] PHP code is unnecessarily trimmed


Chen
Mon 25th Nov '02, 4:28pm
This is a bug in both vB2 and vB3, trim() should not be used here:
if (strpos($code, '<'.'?') === false)
{
$code = '<'.'? ' . trim($code) . ' ?'.'>';
$addedtags = 1;
}
Why? View this post's source and see for yourself.

Kier
Thu 23rd Jan '03, 6:57am
Um... can you be a bit more specific? I've looked at your post and I can't see any differences?

Stadler
Thu 23rd Jan '03, 7:19am
There should be a space in front of the 'if', but all whitespaces in front of the first tag are being stripped, which is breaking the structure of the code.

I think you should use chop instead of trim.

Kier
Thu 23rd Jan '03, 7:43am
If that's all it is, then fixed

Kier
Thu 23rd Jan '03, 7:44am
$validtypes = array(
'A' => 'upper-alpha',
'a' => 'lower-alpha',
'I' => 'upper-roman',
'i' => 'lower-roman',
'1' => 'decimal'
);
if (empty($type) or !isset($validtypes["$type"]))
{
//$attribute = ' style="list-style-type:disc"';
$attribute = '';
}...?

Stadler
Thu 23rd Jan '03, 7:50am
Looks fine for me now :)

Chen
Thu 23rd Jan '03, 8:21am
echo 'Great!';
:)

Hmm, not so great after all... it replaced my (2) tabs with *shudder* spaces.

Kier
Thu 23rd Jan '03, 9:24am
Not a lot I can do about that... use the non-WYSIWYG editor to preserve full formatting.