Posted by sillygwailo on September 17, 2009 at 6:31pm
| Project: | G2 Glossary |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | sillygwailo |
| Status: | closed (fixed) |
Issue Summary
The attached patch adds an 'e' modifier to the regular expression so that the replacement can be evaluated as PHP code. The patch also includes the last parameter for the hook_filter and changes a double-quote to a single quote in the filter operations.
Comments
#1
#2
Needs to be converted to the "new" format no longer depending on invalid UTF8 sequences.
See #267484: Incorrect filter documentation for details.
#3
#4
It probably means something like this:
<?php
case 'prepare':
- // Note: we use the bytes 0xFE and 0xFF to replace < > during the filtering process.
- // These bytes are not valid in UTF-8 data and thus least likely to cause problems.
- $text = preg_replace('@<dfn>(.+?)</dfn>@s', "\xFEdfn\xFF\\1\xFE/dfn\xFF", $text);
+ $text = preg_replace('@<dfn>(.+?)</dfn>@s', "[g2-dfn]\\1[/g2-dfn]", $text);
return $text;
case "process":
- $text = preg_replace('@\xFEdfn\xFF(.+?)\xFE/dfn\xFF@se', "_g2_filter_process('$1')", $text);
+ $text = preg_replace('@\[g2-dfn\](.+?)\[/g2-dfn\]@se', "_g2_filter_process('$1')", $text);
return $text;
?>
Or maybe a simpler form in just one step, without prepare. The process callback seems to be unavoidable, though.
#5
Attaching a patch. Includes modification of the comments to reflect current practice.
#6
#7
Looks good to me. I've included it in the dev. version (off-CVS for now).
#8
Included in today's release, with a zillion other changes.
#9
Automatically closed -- issue fixed for 2 weeks with no activity.