anshuwap / glossword

Automatically exported from code.google.com/p/glossword
0 stars 0 forks source link

v1.8.11 - func.text.inc.php - function text_highlight() - bug in html output #122

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
= What steps will reproduce the problem?
1. when a search matches one or more letters contained in "strong class
highlight"
2. the result page is incorrectly html parsed

= What is the expected output? What do you see instead?
normal highlight for match

= What version of the product are you using? On what operating system?
1.8.11

= Please provide any additional information below.

0. here is a fix
00. characters '†' and '‡' were chosen arbitrarily
000. not the better fix, but it works
0000. feel free to find a better solution !

in "func.text.inc.php", after #449

1.
= find: $classname = 'highlight';

> put after :
$strong_start = '†';
$strong_end = '‡';

2.
= find:
$t = preg_replace('#('.preg_quote($v, '/').')#i', '<strong
class="'.$classname.'">\\1</strong>', $t);

> # and add (or replace with):
$t = preg_replace('#('.preg_quote($v, '/').')#i',
$strong_start.'\\1'.$strong_end, $t);

3.
= find:
$t = preg_replace('#(^|[\x09-\xff])('.preg_quote($v,
'/').')([\x09-\xff]|$)#iu', '\\1<strong
class="'.$classname.'">\\2</strong>\\3', $t);

> # and add (or replace with):
$t = preg_replace('#(^|[\x09-\xff])('.preg_quote($v,
'/').')([\x09-\xff]|$)#iu', '\\1'.$strong_start.'\\2'.$strong_end.'\\3', $t);

4.
= find:
$t = preg_replace('#(^|[\x09-\xff])('.preg_quote($v, '/').')#iu',
'\\1<strong class="'.$classname.'">\\2</strong>', $t);

> # and add (or replace with):
$t = preg_replace('#(^|[\x09-\xff])('.preg_quote($v, '/').')#iu',
'\\1'.$strong_start.'\\2'.$strong_end, $t);

5.
= find:
$t = preg_replace('#('.preg_quote($v, '/').')([\x09-\xff]|$)#iu', '<strong
class="'.$classname.'">\\1</strong>\\2', $t);

> # and add (or replace with):
$t = preg_replace('#('.preg_quote($v, '/').')([\x09-\xff]|$)#iu',
$strong_start.'\\1'.$strong_end, $t);

6.
= find:
# prn_r( $t, __LINE__ );

> add after:
$t = str_replace("†", '<strong class="'.$classname.'">', $t);
$t = str_replace("‡", '</strong>', $t);

Original issue reported on code.google.com by readwr...@gmail.com on 28 Sep 2009 at 12:45

GoogleCodeExporter commented 9 years ago
search examples:
c l a*
l a*
c l

Original comment by readwr...@gmail.com on 28 Sep 2009 at 12:59

GoogleCodeExporter commented 9 years ago
0.
characters '†' and '‡' were chosen arbitrarily

00.
but they can be found in terms or definitions
so i suggest something else (hexadecimal caracters x00 and x01)

000.
replace
$strong_start = '†';
$strong_end = '‡';

by
$strong_start = '\x00';
$strong_end = '\x01';

0000.
and replace
$t = str_replace("†", '<strong class="'.$classname.'">', $t);
$t = str_replace("‡", '</strong>', $t);

by
$t = str_replace($strong_start, '<strong class="'.$classname.'">', $t);
$t = str_replace($strong_end, '</strong>', $t);

Original comment by readwr...@gmail.com on 10 Oct 2009 at 10:48

GoogleCodeExporter commented 9 years ago
Thank you for solving the issue.

Original comment by dmitry.s...@gmail.com on 18 Feb 2010 at 9:05

Attachments: