News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Bug in parser_bbc() function ?

Started by Mizar, October 14, 2005, 08:43:32 AM

Previous topic - Next topic

Mizar

I have posted recently a topic about a problem in the display of topic containing à letter.

I modify the function parse_bbc() in /source/subs.php

// The idea is, find words xx long, and then replace them with xx + space + more.
if (strlen($data) > $modSettings['fixLongWords'])
{
// This is done in a roundabout way because $breaker has "long words" :P.
$data = strtr($data, array($breaker => '< >', '&nbsp;' => "\xA0"));
$data = preg_replace(
'/(?<=[>;:!? \xA0\]()]|^)([\w\.]{' . $modSettings['fixLongWords'] . ',})/e',
"preg_replace('/(.{" . ($modSettings['fixLongWords'] - 1) . "})/', '\\\$1< >', '\$1')",
$data);
$data = strtr($data, array('< >' => $breaker, "\xA0" => '&nbsp;'));
}


changing all occurencies of:

xA0

with

x00A0

Now all my à  letter remain à also when the text is longer than $modSettings['fixLongWords']

P.S.
I don't know if this is valid for all. In my utf-8 forum work good.

Bye

taka

Unfortunately, it's not working as expected.  See following document:

http://us3.php.net/manual/en/language.constants.php [nofollow]

Your code means three characters, null char, 'A' and '0'.  The bug is in the string literal which hardcoded '\xA0' in there.  The right fix is to remove that character. 

SacmaliK


// This is done in a roundabout way because $breaker has "long words" :P.
$data = strtr($data, array($breaker => '< >', '&nbsp;' => $context['utf8'] ? "\xC2\xA0" : "\xA0"));
$data = preg_replace(
'~(?<=[>;:!? ' . ($context['utf8'] ? '\x{C2A0}' : '\xA0') . '\]()]|^)([\w\.]{' . $modSettings['fixLongWords'] . ',})~e' . ($context['utf8'] ? 'u' : ''),
"preg_replace('/(.{" . ($modSettings['fixLongWords'] - 1) . '})/' . ($context['utf8'] ? 'u' : '') . "', '\\\$1< >', '\$1')",
$data);
$data = strtr($data, array('< >' => $breaker, $context['utf8'] ? "\xC2\xA0" : "\xA0" => '&nbsp;'));



I While the message send fatal error  :'(

$data = strtr($data, array($breaker => '< >', '&nbsp;' => $context['utf8'] ? "\xC2\xA0" : "\xA0"));

Is there the mistake?

My Mods
Veoh Bbc Tag:here
Topic get Keywords:here
...

codenaught

I don't see any parse error in the code you posted. Are you sure this change is even needed? This topic was started nearly a year ago and when I tested out posting long words with just "à" in them I didn't see any problems.
Dev Consultant
Former SMF Doc Coordinator

karag8z

bendeki hata images hack eklemelerini kaldırınca çözüldü. popup url + pop up image duruyor. images hack entegrasyonunu nasıl çözerim bilmem ama

Advertisement: