From 6bca068bbe5ed6a2334d2827ba254052d5a53db0 Mon Sep 17 00:00:00 2001 From: Denis Flaven Date: Thu, 14 Jun 2012 09:14:47 +0000 Subject: [PATCH] Fixed Trac #558: properly parse strings containing hexadecimal sequences (i.e. 'QWERTY0xCUIOP'). Note that for now hexadecimal numbers are parsed but not interpreted properly... SVN:1.2.1[2102] --- core/oql/oql-lexer.php | 2 +- core/oql/oql-lexer.plex | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/core/oql/oql-lexer.php b/core/oql/oql-lexer.php index ada6d5519..93bd5bd71 100644 --- a/core/oql/oql-lexer.php +++ b/core/oql/oql-lexer.php @@ -168,7 +168,7 @@ class OQLLexerRaw '/\GABOVE STRICT/ ', '/\GNOT ABOVE/ ', '/\GNOT ABOVE STRICT/ ', - '/\G[0-9]+|0x[0-9a-fA-F]+/ ', + '/\G(0x[0-9a-fA-F]+|[0-9]+)/ ', '/\G\"([^\\\\\"]|\\\\\"|\\\\\\\\)*\"|'.chr(94).chr(39).'([^\\\\'.chr(39).']|\\\\'.chr(39).'|\\\\\\\\)*'.chr(39).'/ ', '/\G([_a-zA-Z][_a-zA-Z0-9]*|`[^`]+`)/ ', '/\G:([_a-zA-Z][_a-zA-Z0-9]*->[_a-zA-Z][_a-zA-Z0-9]*|[_a-zA-Z][_a-zA-Z0-9]*)/ ', diff --git a/core/oql/oql-lexer.plex b/core/oql/oql-lexer.plex index 1e2c837b9..66832ef39 100644 --- a/core/oql/oql-lexer.plex +++ b/core/oql/oql-lexer.plex @@ -140,7 +140,23 @@ above = "ABOVE" above_strict = "ABOVE STRICT" not_above = "NOT ABOVE" not_above_strict = "NOT ABOVE STRICT" -numval = /[0-9]+|0x[0-9a-fA-F]+/ +// +// WARNING: there seems to be a bug in the Lexer about matching the longest pattern +// when there are alternates in the regexp. +// +// For instance: +// numval = /[0-9]+|0x[0-9a-fA-F]+/ +// Does not work: SELECT Toto WHERE name = 'Text0xCTest' => Fails because 0xC is recongnized as a numval (inside the string) instead of a strval !! +// +// Inserting a ^ after the alternate (see comment at the top of this file) does not work either +// numval = /[0-9]+|'.chr(94).'0x[0-9a-fA-F]+/ +// SELECT Toto WHERE name = 'Text0xCTest' => works but +// SELECT Toto WHERE id = 0xC => does not work, 'xC' is found as a name (apparently 0 is recognized as a numval and the remaining is a name !) +// +// numval = /([0-9]+|0x[0-9a-fA-F]+)/ +// Does not work either, the hexadecimal numbers are not matched properly +// The following seems to work... +numval = /(0x[0-9a-fA-F]+|[0-9]+)/ strval = /"([^\\"]|\\"|\\\\)*"|'.chr(94).chr(39).'([^\\'.chr(39).']|\\'.chr(39).'|\\\\)*'.chr(39).'/ name = /([_a-zA-Z][_a-zA-Z0-9]*|`[^`]+`)/ varname = /:([_a-zA-Z][_a-zA-Z0-9]*->[_a-zA-Z][_a-zA-Z0-9]*|[_a-zA-Z][_a-zA-Z0-9]*)/