View Issue Details

IDProjectCategoryView StatusLast Update
0033370PatchesPatchpublic2020-03-20 11:17
ReporterDenis GrinyukAssigned ToJuha Manninen 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionreopened 
Product VersionProduct Build 
Target VersionFixed in Version 
Summary0033370: Password masking in LCL.InputQuery (Delphi compatibility)
DescriptionControl character in first position of Label caption makes Edit password-masked.

Exists in Delphi XE6 Vcl.Dialogs

Described here: http://docwiki.embarcadero.com/Libraries/XE8/en/FMX.Dialogs.InputQuery#Masking_a_Field
TagsNo tags attached.
Fixed in Revisionr58949, r62777
LazTarget-
Widgetset
Attached Files
  • 0001-LCL-InputQuery-Password-masking-Delphi-compatibility.patch (2,012 bytes)
    From e8c54f2b267b856f0af7a2137a8a060e9087cfb0 Mon Sep 17 00:00:00 2001
    From: Denis Grinyuk <denis.grinyuk@gmail.com>
    Date: Fri, 13 Oct 2017 18:01:54 +0300
    Subject: [PATCH] LCL: InputQuery: Password masking (Delphi compatibility)
    
    Control character in first position of Label caption makes Edit password-masked.
    
    Exists in Delphi XE6 Vcl.Dialogs
    Described here: http://docwiki.embarcadero.com/Libraries/XE8/en/FMX.Dialogs.InputQuery#Masking_a_Field
    ---
     lcl/include/messagedialogs.inc | 21 ++++++++++++++++++++-
     1 file changed, 20 insertions(+), 1 deletion(-)
    
    diff --git a/lcl/include/messagedialogs.inc b/lcl/include/messagedialogs.inc
    index 5f91fe6..e425bda 100644
    --- a/lcl/include/messagedialogs.inc
    +++ b/lcl/include/messagedialogs.inc
    @@ -385,6 +385,23 @@ var
       FButtons: TButtonPanel;
       FForm: TDummyForInput;
       Len, NSpacing, NEditWidth, i: integer;
    +
    +  function GetPromptCaption(const APrompt: string): string;
    +  begin
    +    if (Length(APrompt) > 1) and (APrompt[1] < #32) then
    +      Result := Copy(APrompt, 2, Length(APrompt) - 1)
    +    else
    +      Result := APrompt;
    +  end;
    +
    +  function GetPasswordChar(const APrompt: string): Char;
    +  begin
    +    if (Length(APrompt) > 1) and (APrompt[1] < #32) then
    +      Result := '*'
    +    else
    +      Result := #0;
    +  end;
    +
     begin
       Result:= false;
       if Length(APrompts)<1 then
    @@ -436,6 +453,8 @@ begin
         FEdits[i].Align:= alRight;
         FEdits[i].Width:= NEditWidth;
         FEdits[i].Text:= AValues[i];
    +    if i<Length(APrompts) then
    +      FEdits[i].PasswordChar:= GetPasswordChar(APrompts[i]);
     
         FLabels[i]:= TPanel.Create(FForm);
         FLabels[i].Parent:= FPanels[i];
    @@ -443,7 +462,7 @@ begin
         FLabels[i].BevelInner:= bvNone;
         FLabels[i].BevelOuter:= bvNone;
         if i<Length(APrompts) then
    -      FLabels[i].Caption:= APrompts[i];
    +      FLabels[i].Caption:= GetPromptCaption(APrompts[i]);
         FLabels[i].BorderSpacing.Right:= NSpacing;
         FLabels[i].Width:= FLabels[i].Canvas.TextWidth(FLabels[i].Caption);
     
    -- 
    1.9.5.msysgit.1
    
    
  • 0002-LCL-InputQuery-Password-masking-Delphi-compatibility.patch (4,465 bytes)
    Index: lcl/include/messagedialogs.inc
    ===================================================================
    --- lcl/include/messagedialogs.inc	(revision 58950)
    +++ lcl/include/messagedialogs.inc	(working copy)
    @@ -414,68 +414,68 @@
       SetLength(FEdits, Len);
     
       FForm:= TDummyForInput.CreateNew(nil);
    -  FForm.Width:= FForm.Scale96ToForm(600);
    -  FForm.Height:= FForm.Scale96ToForm(400);
    -  FForm.BorderStyle:= bsDialog;
    -  FForm.Position:= poScreenCenter;
    -  FForm.Caption:= ACaption;
    -  FForm.FOnCloseEvent:= ACloseEvent;
    +  try
    +    FForm.Width:= FForm.Scale96ToForm(600);
    +    FForm.Height:= FForm.Scale96ToForm(400);
    +    FForm.BorderStyle:= bsDialog;
    +    FForm.Position:= poScreenCenter;
    +    FForm.Caption:= ACaption;
    +    FForm.FOnCloseEvent:= ACloseEvent;
     
    -  NSpacing:= FForm.Scale96ToForm(cInputQuerySpacingSize);
    -  NEditWidth:= Max(
    -    FForm.Scale96ToForm(cInputQueryEditSizePixels),
    -    _InputQueryActiveMonitor.Width * cInputQueryEditSizePercents div 100);
    +    NSpacing:= FForm.Scale96ToForm(cInputQuerySpacingSize);
    +    NEditWidth:= Max(
    +      FForm.Scale96ToForm(cInputQueryEditSizePixels),
    +      _InputQueryActiveMonitor.Width * cInputQueryEditSizePercents div 100);
     
    -  FButtons:= TButtonPanel.Create(FForm);
    -  FButtons.Parent:= FForm;
    -  FButtons.ShowButtons:= [pbOK, pbCancel];
    -  FButtons.ShowBevel:= false;
    -  FButtons.OKButton.OnClick:= @FForm.FOnClick;
    -  FButtons.OKButton.ModalResult:= mrNone;
    +    FButtons:= TButtonPanel.Create(FForm);
    +    FButtons.Parent:= FForm;
    +    FButtons.ShowButtons:= [pbOK, pbCancel];
    +    FButtons.ShowBevel:= false;
    +    FButtons.OKButton.OnClick:= @FForm.FOnClick;
    +    FButtons.OKButton.ModalResult:= mrNone;
     
    -  for i:= 0 to Len-1 do
    -  begin
    -    FPanels[i]:= TPanel.Create(FForm);
    -    FPanels[i].Parent:= FForm;
    -    FPanels[i].Align:= alTop;
    -    FPanels[i].BevelInner:= bvNone;
    -    FPanels[i].BevelOuter:= bvNone;
    -    FPanels[i].AutoSize:= true;
    -    FPanels[i].BorderSpacing.Around:= NSpacing;
    +    for i:= 0 to Len-1 do
    +    begin
    +      FPanels[i]:= TPanel.Create(FForm);
    +      FPanels[i].Parent:= FForm;
    +      FPanels[i].Align:= alTop;
    +      FPanels[i].BevelInner:= bvNone;
    +      FPanels[i].BevelOuter:= bvNone;
    +      FPanels[i].AutoSize:= true;
    +      FPanels[i].BorderSpacing.Around:= NSpacing;
     
    -    //fix order of panels
    -    if i>0 then
    -      FPanels[i].Top:= FPanels[i-1].Top+10;
    +      //fix order of panels
    +      if i>0 then
    +        FPanels[i].Top:= FPanels[i-1].Top+10;
     
    -    FEdits[i]:= TEdit.Create(FForm);
    -    FEdits[i].Parent:= FPanels[i];
    -    FEdits[i].Align:= alRight;
    -    FEdits[i].Width:= NEditWidth;
    -    FEdits[i].Text:= AValues[i];
    -    if i<Length(APrompts) then
    -      FEdits[i].PasswordChar:= GetPasswordChar(APrompts[i]);
    +      FEdits[i]:= TEdit.Create(FForm);
    +      FEdits[i].Parent:= FPanels[i];
    +      FEdits[i].Align:= alRight;
    +      FEdits[i].Width:= NEditWidth;
    +      FEdits[i].Text:= AValues[i];
    +      if i<Length(APrompts) then
    +        FEdits[i].PasswordChar:= GetPasswordChar(APrompts[i]);
     
    -    FLabels[i]:= TPanel.Create(FForm);
    -    FLabels[i].Parent:= FPanels[i];
    -    FLabels[i].Align:= alRight;
    -    FLabels[i].BevelInner:= bvNone;
    -    FLabels[i].BevelOuter:= bvNone;
    -    if i<Length(APrompts) then
    -      FLabels[i].Caption:= GetPromptCaption(APrompts[i]);
    -    FLabels[i].BorderSpacing.Right:= NSpacing;
    -    FLabels[i].Width:= FLabels[i].Canvas.TextWidth(FLabels[i].Caption);
    +      FLabels[i]:= TPanel.Create(FForm);
    +      FLabels[i].Parent:= FPanels[i];
    +      FLabels[i].Align:= alRight;
    +      FLabels[i].BevelInner:= bvNone;
    +      FLabels[i].BevelOuter:= bvNone;
    +      if i<Length(APrompts) then
    +        FLabels[i].Caption:= GetPromptCaption(APrompts[i]);
    +      FLabels[i].BorderSpacing.Right:= NSpacing;
    +      FLabels[i].Width:= FLabels[i].Canvas.TextWidth(FLabels[i].Caption);
     
    -    FEdits[i].Left:= FForm.Width; // place edits to right
    -  end;
    +      FEdits[i].Left:= FForm.Width; // place edits to right
    +    end;
     
    -  FButtons.Align:= alTop;
    -  FButtons.Top:= FPanels[Len-1].Top+10; // place buttons to bottom
    +    FButtons.Align:= alTop;
    +    FButtons.Top:= FPanels[Len-1].Top+10; // place buttons to bottom
     
    -  FForm.AutoSize:= true;
    -  FForm.ActiveControl:= FEdits[0];
    -  FForm.FEditsPtr:= @FEdits;
    +    FForm.AutoSize:= true;
    +    FForm.ActiveControl:= FEdits[0];
    +    FForm.FEditsPtr:= @FEdits;
     
    -  try
         Result:= FForm.ShowModal=mrOk;
         if Result then
           for i:= 0 to Len-1 do
    

Activities

Denis Grinyuk

2018-03-07 14:33

reporter  

0001-LCL-InputQuery-Password-masking-Delphi-compatibility.patch (2,012 bytes)
From e8c54f2b267b856f0af7a2137a8a060e9087cfb0 Mon Sep 17 00:00:00 2001
From: Denis Grinyuk <denis.grinyuk@gmail.com>
Date: Fri, 13 Oct 2017 18:01:54 +0300
Subject: [PATCH] LCL: InputQuery: Password masking (Delphi compatibility)

Control character in first position of Label caption makes Edit password-masked.

Exists in Delphi XE6 Vcl.Dialogs
Described here: http://docwiki.embarcadero.com/Libraries/XE8/en/FMX.Dialogs.InputQuery#Masking_a_Field
---
 lcl/include/messagedialogs.inc | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/lcl/include/messagedialogs.inc b/lcl/include/messagedialogs.inc
index 5f91fe6..e425bda 100644
--- a/lcl/include/messagedialogs.inc
+++ b/lcl/include/messagedialogs.inc
@@ -385,6 +385,23 @@ var
   FButtons: TButtonPanel;
   FForm: TDummyForInput;
   Len, NSpacing, NEditWidth, i: integer;
+
+  function GetPromptCaption(const APrompt: string): string;
+  begin
+    if (Length(APrompt) > 1) and (APrompt[1] < #32) then
+      Result := Copy(APrompt, 2, Length(APrompt) - 1)
+    else
+      Result := APrompt;
+  end;
+
+  function GetPasswordChar(const APrompt: string): Char;
+  begin
+    if (Length(APrompt) > 1) and (APrompt[1] < #32) then
+      Result := '*'
+    else
+      Result := #0;
+  end;
+
 begin
   Result:= false;
   if Length(APrompts)<1 then
@@ -436,6 +453,8 @@ begin
     FEdits[i].Align:= alRight;
     FEdits[i].Width:= NEditWidth;
     FEdits[i].Text:= AValues[i];
+    if i<Length(APrompts) then
+      FEdits[i].PasswordChar:= GetPasswordChar(APrompts[i]);
 
     FLabels[i]:= TPanel.Create(FForm);
     FLabels[i].Parent:= FPanels[i];
@@ -443,7 +462,7 @@ begin
     FLabels[i].BevelInner:= bvNone;
     FLabels[i].BevelOuter:= bvNone;
     if i<Length(APrompts) then
-      FLabels[i].Caption:= APrompts[i];
+      FLabels[i].Caption:= GetPromptCaption(APrompts[i]);
     FLabels[i].BorderSpacing.Right:= NSpacing;
     FLabels[i].Width:= FLabels[i].Canvas.TextWidth(FLabels[i].Caption);
 
-- 
1.9.5.msysgit.1

CudaText man

2018-03-07 20:51

reporter   ~0106974

+ if (Length(APrompt) > 1) and (APrompt[1] < 0000032) then
+ Result := Copy(APrompt, 2, Length(APrompt) - 1)
+ else
+ Result := APrompt;


->

Result:= APrompt;
if (Result<>'') and (Result[1]<' ') then
  Delete(Result, 1, 1);

Juha Manninen

2018-09-11 10:52

developer   ~0110638

Applied, thanks.
The optimization by AlexeyT was valid. I applied it, too.

Serge Anvarov

2018-09-11 11:42

reporter   ~0110648

Can also fix the "try" block. The included patch moves the "try" keyword to the correct location with the remaining code indented.

Serge Anvarov

2018-09-11 11:42

reporter  

0002-LCL-InputQuery-Password-masking-Delphi-compatibility.patch (4,465 bytes)
Index: lcl/include/messagedialogs.inc
===================================================================
--- lcl/include/messagedialogs.inc	(revision 58950)
+++ lcl/include/messagedialogs.inc	(working copy)
@@ -414,68 +414,68 @@
   SetLength(FEdits, Len);
 
   FForm:= TDummyForInput.CreateNew(nil);
-  FForm.Width:= FForm.Scale96ToForm(600);
-  FForm.Height:= FForm.Scale96ToForm(400);
-  FForm.BorderStyle:= bsDialog;
-  FForm.Position:= poScreenCenter;
-  FForm.Caption:= ACaption;
-  FForm.FOnCloseEvent:= ACloseEvent;
+  try
+    FForm.Width:= FForm.Scale96ToForm(600);
+    FForm.Height:= FForm.Scale96ToForm(400);
+    FForm.BorderStyle:= bsDialog;
+    FForm.Position:= poScreenCenter;
+    FForm.Caption:= ACaption;
+    FForm.FOnCloseEvent:= ACloseEvent;
 
-  NSpacing:= FForm.Scale96ToForm(cInputQuerySpacingSize);
-  NEditWidth:= Max(
-    FForm.Scale96ToForm(cInputQueryEditSizePixels),
-    _InputQueryActiveMonitor.Width * cInputQueryEditSizePercents div 100);
+    NSpacing:= FForm.Scale96ToForm(cInputQuerySpacingSize);
+    NEditWidth:= Max(
+      FForm.Scale96ToForm(cInputQueryEditSizePixels),
+      _InputQueryActiveMonitor.Width * cInputQueryEditSizePercents div 100);
 
-  FButtons:= TButtonPanel.Create(FForm);
-  FButtons.Parent:= FForm;
-  FButtons.ShowButtons:= [pbOK, pbCancel];
-  FButtons.ShowBevel:= false;
-  FButtons.OKButton.OnClick:= @FForm.FOnClick;
-  FButtons.OKButton.ModalResult:= mrNone;
+    FButtons:= TButtonPanel.Create(FForm);
+    FButtons.Parent:= FForm;
+    FButtons.ShowButtons:= [pbOK, pbCancel];
+    FButtons.ShowBevel:= false;
+    FButtons.OKButton.OnClick:= @FForm.FOnClick;
+    FButtons.OKButton.ModalResult:= mrNone;
 
-  for i:= 0 to Len-1 do
-  begin
-    FPanels[i]:= TPanel.Create(FForm);
-    FPanels[i].Parent:= FForm;
-    FPanels[i].Align:= alTop;
-    FPanels[i].BevelInner:= bvNone;
-    FPanels[i].BevelOuter:= bvNone;
-    FPanels[i].AutoSize:= true;
-    FPanels[i].BorderSpacing.Around:= NSpacing;
+    for i:= 0 to Len-1 do
+    begin
+      FPanels[i]:= TPanel.Create(FForm);
+      FPanels[i].Parent:= FForm;
+      FPanels[i].Align:= alTop;
+      FPanels[i].BevelInner:= bvNone;
+      FPanels[i].BevelOuter:= bvNone;
+      FPanels[i].AutoSize:= true;
+      FPanels[i].BorderSpacing.Around:= NSpacing;
 
-    //fix order of panels
-    if i>0 then
-      FPanels[i].Top:= FPanels[i-1].Top+10;
+      //fix order of panels
+      if i>0 then
+        FPanels[i].Top:= FPanels[i-1].Top+10;
 
-    FEdits[i]:= TEdit.Create(FForm);
-    FEdits[i].Parent:= FPanels[i];
-    FEdits[i].Align:= alRight;
-    FEdits[i].Width:= NEditWidth;
-    FEdits[i].Text:= AValues[i];
-    if i<Length(APrompts) then
-      FEdits[i].PasswordChar:= GetPasswordChar(APrompts[i]);
+      FEdits[i]:= TEdit.Create(FForm);
+      FEdits[i].Parent:= FPanels[i];
+      FEdits[i].Align:= alRight;
+      FEdits[i].Width:= NEditWidth;
+      FEdits[i].Text:= AValues[i];
+      if i<Length(APrompts) then
+        FEdits[i].PasswordChar:= GetPasswordChar(APrompts[i]);
 
-    FLabels[i]:= TPanel.Create(FForm);
-    FLabels[i].Parent:= FPanels[i];
-    FLabels[i].Align:= alRight;
-    FLabels[i].BevelInner:= bvNone;
-    FLabels[i].BevelOuter:= bvNone;
-    if i<Length(APrompts) then
-      FLabels[i].Caption:= GetPromptCaption(APrompts[i]);
-    FLabels[i].BorderSpacing.Right:= NSpacing;
-    FLabels[i].Width:= FLabels[i].Canvas.TextWidth(FLabels[i].Caption);
+      FLabels[i]:= TPanel.Create(FForm);
+      FLabels[i].Parent:= FPanels[i];
+      FLabels[i].Align:= alRight;
+      FLabels[i].BevelInner:= bvNone;
+      FLabels[i].BevelOuter:= bvNone;
+      if i<Length(APrompts) then
+        FLabels[i].Caption:= GetPromptCaption(APrompts[i]);
+      FLabels[i].BorderSpacing.Right:= NSpacing;
+      FLabels[i].Width:= FLabels[i].Canvas.TextWidth(FLabels[i].Caption);
 
-    FEdits[i].Left:= FForm.Width; // place edits to right
-  end;
+      FEdits[i].Left:= FForm.Width; // place edits to right
+    end;
 
-  FButtons.Align:= alTop;
-  FButtons.Top:= FPanels[Len-1].Top+10; // place buttons to bottom
+    FButtons.Align:= alTop;
+    FButtons.Top:= FPanels[Len-1].Top+10; // place buttons to bottom
 
-  FForm.AutoSize:= true;
-  FForm.ActiveControl:= FEdits[0];
-  FForm.FEditsPtr:= @FEdits;
+    FForm.AutoSize:= true;
+    FForm.ActiveControl:= FEdits[0];
+    FForm.FEditsPtr:= @FEdits;
 
-  try
     Result:= FForm.ShowModal=mrOk;
     if Result then
       for i:= 0 to Len-1 do

Juha Manninen

2020-03-20 11:17

developer   ~0121658

I applied the second patch. Thanks.
Please reopen the issue in future if it needs further attention.

Issue History

Date Modified Username Field Change
2018-03-07 14:33 Denis Grinyuk New Issue
2018-03-07 14:33 Denis Grinyuk File Added: 0001-LCL-InputQuery-Password-masking-Delphi-compatibility.patch
2018-03-07 20:51 CudaText man Note Added: 0106974
2018-09-11 01:36 Juha Manninen Assigned To => Juha Manninen
2018-09-11 01:36 Juha Manninen Status new => assigned
2018-09-11 10:52 Juha Manninen Fixed in Revision => r58949
2018-09-11 10:52 Juha Manninen LazTarget => -
2018-09-11 10:52 Juha Manninen Note Added: 0110638
2018-09-11 10:52 Juha Manninen Status assigned => resolved
2018-09-11 10:52 Juha Manninen Resolution open => fixed
2018-09-11 11:42 Serge Anvarov Note Added: 0110648
2018-09-11 11:42 Serge Anvarov File Added: 0002-LCL-InputQuery-Password-masking-Delphi-compatibility.patch
2020-03-19 21:54 Juha Manninen Status resolved => assigned
2020-03-19 21:54 Juha Manninen Resolution fixed => reopened
2020-03-20 11:17 Juha Manninen Status assigned => resolved
2020-03-20 11:17 Juha Manninen Fixed in Revision r58949 => r58949, r62777
2020-03-20 11:17 Juha Manninen Note Added: 0121658