View Issue Details

IDProjectCategoryView StatusLast Update
0005909JEDI VCL00 JVCL Componentspublic2020-12-09 11:07
ReporterAriochAssigned To 
PrioritynormalSeverityminorReproducibilityalways
Status acknowledgedResolutionopen 
Product VersionDaily / GIT 
Target VersionDaily / GITFixed in Version 
Summary0005909: RegExpr-validator is broken
DescriptionD:\DelphiProjects\Libs\JediVCL\jvcl\run\JvValidators.pas

However introduced/copied/commited the change quoted below replaced RegExpr search with DOS file mask search.

JvValidators demo is broken, but of course, who runs demo and who would use RegExpr anyway :-)

The change below should be undone. It gets a bit beyond mere simplification
Additional Information 589 7454 15.06.2004 9:39:36 marquardt //=== { TJvRegularExpressionValidator } ======================================
   590 2083 22.06.2003 14:09:41 peter3
   591 11893 10.09.2008 0:45:14 obones function MatchesMask(const Filename, Mask: string{;
   592 11893 10.09.2008 0:45:14 obones const SearchFlags: TSearchFlags = [sfCaseSensitive]}): Boolean;
   593 6489 19.04.2004 3:55:47 ahuser {var
   594 2083 22.06.2003 14:09:41 peter3 URE: TURESearch;
   595 6489 19.04.2004 3:55:47 ahuser SL: TWideStringList;}
   596 2083 22.06.2003 14:09:41 peter3 begin
   597 6448 16.04.2004 21:28:30 peter3 Result := Masks.MatchesMask(Filename, Mask);
   598 6448 16.04.2004 21:28:30 peter3 (*
   599 2083 22.06.2003 14:09:41 peter3 // use the regexp engine in JclUnicode
   600 2083 22.06.2003 14:09:41 peter3 SL := TWideStringList.Create;
   601 2083 22.06.2003 14:09:41 peter3 try
   602 2083 22.06.2003 14:09:41 peter3 URE := TURESearch.Create(SL);
   603 2083 22.06.2003 14:09:41 peter3 try
   604 2083 22.06.2003 14:09:41 peter3 URE.FindPrepare(Mask, SearchFlags);
   605 2083 22.06.2003 14:09:41 peter3 // this could be overkill for long strings and many matches,
   606 2083 22.06.2003 14:09:41 peter3 // but it's a lot simpler than calling FindFirst...
   607 2083 22.06.2003 14:09:41 peter3 Result := URE.FindAll(Filename);
   608 2083 22.06.2003 14:09:41 peter3 finally
   609 2083 22.06.2003 14:09:41 peter3 URE.Free;
   610 2083 22.06.2003 14:09:41 peter3 end;
   611 2083 22.06.2003 14:09:41 peter3 finally
   612 2083 22.06.2003 14:09:41 peter3 SL.Free;
   613 2083 22.06.2003 14:09:41 peter3 end;
   614 6448 16.04.2004 21:28:30 peter3 *)
   615 2083 22.06.2003 14:09:41 peter3 end;
TagsNo tags attached.

Relationships

related to 0005908 acknowledged JEDI VCL little fix for Validators example 
parent of 0005912 new JEDI Code Library TURESearch to be dumped or turned into wrapper around PCRE ? 
Not all the children of this issue are yet resolved or closed.

Activities

wprins

2016-04-01 18:12

reporter   ~0021279

Still present as of this writing 2016-04-01. (Wasted time today trying to use a regular expression validator for the first time. Why is this component not disabled until it's fixed?)

2016-04-01 19:17

 

JvValidators.pas.patch (1,030 bytes)
 jvcl/run/JvValidators.pas | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/jvcl/run/JvValidators.pas b/jvcl/run/JvValidators.pas
index 249d2f0..ae80c07 100644
--- a/jvcl/run/JvValidators.pas
+++ b/jvcl/run/JvValidators.pas
@@ -41,7 +41,7 @@ uses
   JclUnitVersioning,
   {$ENDIF UNITVERSIONING}
   Windows, SysUtils, Classes, Controls, Forms,
-  JvComponentBase, JvErrorIndicator;
+  JvComponentBase, JvErrorIndicator, JclPCRE;
 
 type
   EValidatorError = class(Exception);
@@ -618,9 +618,16 @@ end;
 procedure TJvRegularExpressionValidator.Validate;
 var
   R: string;
+  re : TJclAnsiRegEx;
 begin
   R := VarToStr(GetValidationPropertyValue);
-  Valid := (R = ValidationExpression) or MatchesMask(R, ValidationExpression);
+  Valid := (R = ValidationExpression);
+  if not Valid then
+  begin
+    re := TJclAnsiRegEx.Create;
+    re.Compile(ValidationExpression,False);
+    Valid := re.Match(R);
+  end;
 end;
 
 //=== { TJvCompareValidator } ================================================
JvValidators.pas.patch (1,030 bytes)

wprins

2016-04-01 19:19

reporter   ~0021280

Uploaded simple fix with JclPCRE.TJclAnsiRegEx, which fixes the component for my use case. Probably needs more testing/review.

alexwriter

2020-12-09 11:07

reporter   ~0021958

595 6489 19.04.2004 3:55:47 ahuser SL: TWideStringList;}
   596 2083 22.06.2003 14:09:41 peter3 https://goo.gl/2DqXGj begin
   597 6448 16.04.2004 21:28:30 peter3 Result := Masks.MatchesMask(Filename, Mask);
   598 6448 16.04.2004 21:28:30 peter3 (*
   599 2083 22.06.2003 14:09:41 peter3 // use the regexp engine in JclUnicode
   600 2083 22.06.2003 14:09:41 peter3 SL := TWideStringList.Create;

Issue History

Date Modified Username Field Change
2012-06-14 14:00 Arioch New Issue
2012-06-14 14:00 Arioch Relationship added related to 0005908
2012-06-14 16:21 Arioch Relationship added parent of 0005912
2012-06-18 11:24 obones Status new => acknowledged
2016-04-01 18:12 wprins Note Added: 0021279
2016-04-01 19:17 wprins File Added: JvValidators.pas.patch
2016-04-01 19:19 wprins Note Added: 0021280
2020-12-09 11:07 alexwriter Note Added: 0021958