Download & Extend

Evaluate the replacement as PHP code, bring G2 hook_filter implementation up to speed with Drupal 6

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

AttachmentSizeStatusTest resultOperations
580576-evaluate-replacement.patch1.06 KBIgnored: Check issue status.NoneNone

#2

Status:active» needs work

Needs to be converted to the "new" format no longer depending on invalid UTF8 sequences.

See #267484: Incorrect filter documentation for details.

#3

Assigned to:Anonymous» sillygwailo

#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.

AttachmentSizeStatusTest resultOperations
580576-evaluate-replacement-plus-placeholders.patch.txt1.42 KBIgnored: Check issue status.NoneNone

#6

Status:needs work» needs review

#7

Status:needs review» reviewed & tested by the community

Looks good to me. I've included it in the dev. version (off-CVS for now).

#8

Status:reviewed & tested by the community» fixed

Included in today's release, with a zillion other changes.

#9

Status:fixed» closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

nobody click here