View Issue Details

IDProjectCategoryView StatusLast Update
0038676LazarusLCLpublic2021-04-12 09:29
ReporterAndrey Zubarev Assigned ToMaxim Ganetsky  
PrioritynormalSeverityminorReproducibilityhave not tried
Status closedResolutionfixed 
Fixed in Version2.2 
Summary0038676: LCLTaskDialog prevent \n conversion to LF
Descriptionhere https://forum.lazarus.freepascal.org/index.php/topic,53884.0.html
Attached path add escaped \ processing
TagsNo tags attached.
Fixed in Revision64975
LazTarget-
Widgetset
Attached Files

Activities

Andrey Zubarev

2021-03-28 14:50

reporter   ~0129939

lcltaskdialog.pas.patch (758 bytes)   
Index: lcl/lcltaskdialog.pas
===================================================================
--- lcl/lcltaskdialog.pas	(revision 64866)
+++ lcl/lcltaskdialog.pas	(working copy)
@@ -129,7 +129,7 @@
   {$IFDEF MSWINDOWS}
   Windows,
   {$ENDIF}
-  Classes, SysUtils,
+  Classes, SysUtils, StrUtils,
   LazUTF8,
   LCLType, LCLStrConsts, LCLIntf, InterfaceBase,
   LResources, Menus, Graphics, Forms, Controls, StdCtrls, ExtCtrls, Buttons;
@@ -563,9 +563,9 @@
 
 function CR(const aText: string): string;
 begin
-  if pos('\n', aText) = 0 then
+  if pos('\', aText) = 0 then
     result := aText else
-    result := StringReplace(aText, '\n', #10, [rfReplaceAll]);
+    result := StringsReplace(aText,['\\','\n'],['\',#10], [rfReplaceAll]);
 end;
 
 
lcltaskdialog.pas.patch (758 bytes)   

Maxim Ganetsky

2021-04-04 23:56

developer   ~0130091

I am afraid, this patch won't be applied. It makes user to escape every \ symbol which is unpascalish.

Better to remove handling of \n in Content field at all. In this case users will need to use 'LineEnding' constant in order to get multilined string. Such a patch WILL be applied.

Andrey Zubarev

2021-04-06 21:36

reporter   ~0130143

>>It makes user to escape every \ symbol which is unpascalish.
no only \n escape to \\n if not need line feed, otherwise, the behavior remains the same
It makes user to escape every \\ to \\\\ оr \\\

I think this option is the only one that will keep the old code working

Maxim Ganetsky

2021-04-07 16:00

developer   ~0130155

Last edited: 2021-04-07 16:03

View 2 revisions

> It makes user to escape every \\ to \\\\ оr \\\

That's the point, the change is already backwards incompatible. Moreover, users will need to review their strings and escape '\' if 'n' is present after it if needed. In practice it will be easier to always escape '\' as it will not be always possible to predict if 'n' will follow '\' or not.

The current behavior is considered buggy and we don't want it to be default, so there is simply no backwards compatible way out, because users may rely on it. So better to bite the bullet and remove handling of \n in Content field at all. Inserting newlines will be achieved using LineEnding constants then.

Maxim Ganetsky

2021-04-11 22:05

developer   ~0130289

Last edited: 2021-04-11 23:15

View 2 revisions

Please test and close if OK, '\n' sequence is not converted in Content field anymore.

Andrey Zubarev

2021-04-12 09:29

reporter   ~0130300

Thanks!

Issue History

Date Modified Username Field Change
2021-03-28 14:49 Andrey Zubarev New Issue
2021-03-28 14:50 Andrey Zubarev Note Added: 0129939
2021-03-28 14:50 Andrey Zubarev File Added: lcltaskdialog.pas.patch
2021-04-04 23:56 Maxim Ganetsky Status new => feedback
2021-04-04 23:56 Maxim Ganetsky LazTarget => -
2021-04-04 23:56 Maxim Ganetsky Note Added: 0130091
2021-04-06 21:36 Andrey Zubarev Note Added: 0130143
2021-04-06 21:36 Andrey Zubarev Status feedback => new
2021-04-07 16:00 Maxim Ganetsky Note Added: 0130155
2021-04-07 16:02 Maxim Ganetsky Status new => feedback
2021-04-07 16:03 Maxim Ganetsky Note Edited: 0130155 View Revisions
2021-04-11 22:05 Maxim Ganetsky Assigned To => Maxim Ganetsky
2021-04-11 22:05 Maxim Ganetsky Status feedback => resolved
2021-04-11 22:05 Maxim Ganetsky Resolution open => fixed
2021-04-11 22:05 Maxim Ganetsky Fixed in Version => 2.2
2021-04-11 22:05 Maxim Ganetsky Fixed in Revision => 64975
2021-04-11 22:05 Maxim Ganetsky Note Added: 0130289
2021-04-11 23:15 Maxim Ganetsky Note Edited: 0130289 View Revisions
2021-04-12 09:29 Andrey Zubarev Status resolved => closed
2021-04-12 09:29 Andrey Zubarev Note Added: 0130300