[pcre-dev] [Bug 587] Matching null characters

Pàgina inicial
Delete this message
Autor: Joy
Data:  
A: pcre-dev
Assumpte: [pcre-dev] [Bug 587] Matching null characters
------- You are receiving this mail because: -------
You are on the CC list for the bug.

http://bugs.exim.org/show_bug.cgi?id=587




--- Comment #2 from Joy <joy@???> 2007-08-24 18:24:56 ---
Thank you for responding so soon, but can you show me how you would use the
compile function with [\x00-\x20]?

Using [\x01-\x20] works just fine for me, but [\x00-\x20] does not. Is there
something special that prcetest does? I'm not really using it... Just the c
classes.

Here's the output I get:

[
length=6 added 0 c=[
PCRE compilation failed at offset 1: missing terminating ] for character
class

Here's what I'm putting in:

char *pattern;

...

strPattern.SetASCII("[\x00-\x20]");
mybuffer = strPattern.GetASCIIBuffer();
pattern = (char *)mybuffer->GetBuffer();

...

re = pcre_compile(
          pattern,              /* the pattern */
          0,                    /* default options */
          &error,               /* for error message */
          &erroffset,           /* for error offset */
          NULL);                /* use default character tables */



Don't worry about the "SetASCII" command, in the end I just end up with a
null terminated string in "pattern"

-----Original Message-----
From: admin@??? [mailto:admin@bugs.exim.org] On Behalf Of Philip
Hazel
Sent: Friday, August 24, 2007 11:38 AM
To: joy@???
Subject: [Bug 587] Matching null characters


------- You are receiving this mail because: -------
You reported the bug.

http://bugs.exim.org/show_bug.cgi?id=587




--- Comment #1 from Philip Hazel <ph10@???> 2007-08-24
16:37:34 --- On Fri, 24 Aug 2007, Joy wrote:

> I'm trying to use regular expressions to match binary strings in
> addition to ASCII strings.
>
> This seems to work great until except, of course, in the case of the
> hex 0. \x00
>
> For example, trying to compile the regex "[\x00-\x20]" produces an
> error because stops after the first bracket.


It works fine for me:

$ ./pcretest
PCRE version 7.3-RC8 2007-08-20

re> /[\x00-\x20]/
data> abc\x00def

0: \x00
data>


OK, that's the next release, but nothing has changed in that area. Here's a
previous release:

$ pcretest
PCRE version 6.6 06-Feb-2006

re> /[\x00-\x20]/
data> abc\x00def

0: \x00
data>


> Since there was a length set for the subject of pcre_exec function, I
> had hoped that all of the buffers were referenced by length and not
> nessessarily by a null terminator.


For pcre_exec(), they are.

> Is there a way to make the compile function use length rather that
> null terminator?


No.

> Any suggestions on the best way to accomplish this?


Use the escape sequence in the data for pcre_compile().


Philip


--
Configure bugmail: http://bugs.exim.org/userprefs.cgi?tab=email