View Issue Details

IDProjectCategoryView StatusLast Update
0026790LazarusLazUtilspublic2014-09-27 20:16
Reporterlaz-andy Assigned ToBart Broersma  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Platformx86_64OSlinux 
Product Version1.2.4 
Target Version1.2.6 
Summary0026790: FindAllFiles: Files not found with "special" characters e.g. german ß
DescriptionFindAllFiles('/any','*.bmp') does not find a File Named "ß.bmp".
Steps To Reproduce* Create a File named "ß.bmp"
* call "FindAllFiles('/any','*.bmp')"
* ß.bmp is not found!
Additional Information*The BUG is in masks.pas in TMask.Matches.
 -> The file is converted to UpperCase ß.bmp -> SS.bmp
 -> The variable L is the Length of AFileName. In this special case L gets wrong.
 -> The attached Patch should fix this.
Tagspatch
Fixed in Revisionr46339
LazTarget-
Widgetset
Attached Files

Activities

laz-andy

2014-09-27 11:13

reporter  

masks.diff (230 bytes)   
***************
*** 411,420 ****
    if fCaseSensitive then
      S := AFileName
    else
-   begin
      S := Utf8UpperCase(AFileName);
-     L := Utf8Length(S);
-   end;
    Result := MatchToEnd(0, 1);
  end;
  
--- 411,417 ----
masks.diff (230 bytes)   

Juha Manninen

2014-09-27 11:26

developer   ~0077721

The patch has wrong format but with a little guess work the change can be applied manually.
laz-andy, how did you make the patch?

Mike Thompson

2014-09-27 11:35

developer  

masks.pas.patch (402 bytes)   
Index: components/lazutils/masks.pas
===================================================================
--- components/lazutils/masks.pas	(revision 46323)
+++ components/lazutils/masks.pas	(working copy)
@@ -411,7 +411,10 @@
   if fCaseSensitive then
     S := AFileName
   else
+  begin
     S := Utf8UpperCase(AFileName);
+    L := Utf8Length(S);
+  end;
   Result := MatchToEnd(0, 1);
 end;
 
masks.pas.patch (402 bytes)   

Mike Thompson

2014-09-27 11:37

developer   ~0077723

Last edited: 2014-09-27 11:37

View 2 revisions

For simplicity for others, I've added a svn patch based on laz-andy's original.
Note: I haven't tested this.

Bart Broersma

2014-09-27 17:40

developer   ~0077742

Thanks for the patch.
Applied and changed comparing Uppercase to comparing Lowercase.
There may still be problems though, when the case-conversion alters the Utf8Length. In that case a mask with a '?' in it (single char) may fail.

In your case (still using UpperCase comparing) the 'ß' became 'SS' which then of course is not a single codepoint anymore.
Since this does not happen in the reverse case ('SS' does not become 'ß') I changed comparing to Lowercase, but there may be languages where this then might fail.

Please test and close if OK.

laz-andy

2014-09-27 20:16

reporter   ~0077753

Thank you for applying the Patch.
I' tested with your modification and it works for me.

Sorry for my wrong patch-format. I used the Lazarus-filecomparer (Tools - Compare Files) to produce it. Next time i will use svn diff.

Issue History

Date Modified Username Field Change
2014-09-27 11:13 laz-andy New Issue
2014-09-27 11:13 laz-andy File Added: masks.diff
2014-09-27 11:24 Juha Manninen Assigned To => Bart Broersma
2014-09-27 11:24 Juha Manninen Status new => assigned
2014-09-27 11:24 Juha Manninen Tag Attached: patch
2014-09-27 11:26 Juha Manninen Note Added: 0077721
2014-09-27 11:35 Mike Thompson File Added: masks.pas.patch
2014-09-27 11:37 Mike Thompson Note Added: 0077723
2014-09-27 11:37 Mike Thompson Note Edited: 0077723 View Revisions
2014-09-27 17:40 Bart Broersma Fixed in Revision => r46339
2014-09-27 17:40 Bart Broersma LazTarget => -
2014-09-27 17:40 Bart Broersma Note Added: 0077742
2014-09-27 17:40 Bart Broersma Status assigned => resolved
2014-09-27 17:40 Bart Broersma Resolution open => fixed
2014-09-27 17:40 Bart Broersma Target Version => 1.2.6
2014-09-27 20:16 laz-andy Note Added: 0077753
2014-09-27 20:16 laz-andy Status resolved => closed