check custom language tags for contain special characters

drimsun - January 11, 2008 - 04:48
Project:GeSHi Filter for syntax highlighting
Version:5.x-2.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:soxofaan
Status:closed
Description

Hi

After installing and activating the GeSHi filter I get

warning: preg_replace_callback() [function.preg-replace-callback]: Unknown modifier '|'

in geshifilter.module on line 1019.
in geshifilter.module on line 1096.

all over the place when testing code highlighting =(

Any idea why this happens? I can't imagine '|' being an invalid regexp in certain php versions?

#1

drimsun - January 11, 2008 - 05:23

Ok I nailed down the problem =)

If you use special characters for custom language tags it may mess up the regexp code
because apparently the special characters aren't escaped with a \

For instance the # in [c#] would abruptly end a regexp and cause errors.

#2

soxofaan - January 11, 2008 - 09:34
Title:warning: preg_replace_callback() [function.preg-replace-callback]: Unknown modifier '|'» custom language tags can't contain special characters

updated title

#3

soxofaan - January 11, 2008 - 10:35
Title:custom language tags can't contain special characters» prevent custom language tags to contain special characters

Extra validation of custom language tags is needed.

For example, custom language tags should:

  • not contain regular expression special characters like '#', '+', '|' and such
  • not equal reserved some not yet defined GeSHi filter specific keywords (e.g. code, blockcode, questionmarkphp, ...)
  • not equal the generic code tags
  • not equal each other

#4

soxofaan - January 14, 2008 - 12:26
Title:prevent custom language tags to contain special characters» check custom language tags for contain special characters
Version:5.x-2.3» 5.x-2.x-dev
Status:active» patch (code needs work)

This is a first version of a patch that should solve the initial problem from #1.
Custom language tags like [c++] and [c#] should work now.

TODO: better validation of custom language tags (see #3)

AttachmentSize
geshifilter_208720_tagchars_4.patch1.33 KB

#5

soxofaan - January 17, 2008 - 15:53
Assigned to:Anonymous» soxofaan
Status:patch (code needs work)» active

committed patch #4: http://drupal.org/cvs?commit=96150, http://drupal.org/cvs?commit=96151

still todo: better validation of custom tags (see #3)

#6

soxofaan - March 22, 2008 - 19:13
Category:bug report» feature request

#7

soxofaan - April 28, 2008 - 22:54
Status:active» patch (to be ported)

fixed in HEAD (for Drupal 6) by http://drupal.org/cvs?commit=113423 (also includes SimpleTest test)

#8

soxofaan - May 27, 2008 - 23:14
Status:patch (to be ported)» fixed

fixed in DRUPAL-5--2 by http://drupal.org/cvs?commit=118057

#9

Anonymous (not verified) - June 10, 2008 - 23:21
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.