View Issue Details

IDProjectCategoryView StatusLast Update
0023320LazarusIDEpublic2018-07-17 00:13
ReporterBenito van der ZanderAssigned ToMartin Friebe 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version1.0.3 (SVN)Product Build1.1 r38276, 2.6.0 x86_64-l.-gtk2 
Target Version1.2.0Fixed in Version1.1 (SVN) 
Summary0023320: IDE hint paint html entities (&..) incorrect
DescriptionIf the displayed value contains a &, the following letter is underlined, and if the characters following the & form a html entity, it is replaced with the value of the entity.
Steps To Reproducevar s: string;
begin
  s := '<a';
  writeln(s);

Move the mouse over s.

The hint shows:

≤a
TagsNo tags attached.
Fixed in Revision39374
LazTarget1.2
WidgetsetGTK, GTK 2, Win32/Win64, WinCE, Carbon
Attached Files
  • strangehint.png (6,795 bytes)
    strangehint.png (6,795 bytes)
  • idehelpmanager.diff (2,165 bytes)
    Index: ide/idehelpmanager.pas
    ===================================================================
    --- ide/idehelpmanager.pas	(revision 39272)
    +++ ide/idehelpmanager.pas	(working copy)
    @@ -460,24 +460,17 @@
             Result:=copy(Result,1,p-1)+copy(Result,EndPos,length(Result));
         end else if Result[p]='&' then begin
           // special chars: &lt; &gt; &amp;
    -      if (Result[p+1]='l') and (Result[p+2]='t') then begin
    -        EndPos:=p+3;
    -        if (EndPos<length(Result)) and (Result[EndPos]=';') then
    -          inc(EndPos);
    -        Result:=copy(Result,1,p-1)+'<'+copy(Result,EndPos,length(Result));
    -      end else
    -      if (Result[p+1]='g') and (Result[p+2]='t') then begin
    -        EndPos:=p+3;
    -        if (EndPos<length(Result)) and (Result[EndPos]=';') then
    -          inc(EndPos);
    -        Result:=copy(Result,1,p-1)+'>'+copy(Result,EndPos,length(Result));
    -      end else
    -      if (Result[p+1]='a') and (Result[p+2]='m') and (Result[p+3]='p') then begin
    -        EndPos:=p+4;
    -        if (EndPos<length(Result)) and (Result[EndPos]=';') then
    -          inc(EndPos);
    -        // double '&' to prevent underlining
    -        Result:=copy(Result,1,p-1)+'&&'+copy(Result,EndPos,length(Result));
    +        if (p+2<Length(Result)) and (Result[p+1]='l') and (Result[p+2]='t') and (Result[p+3]=';') then begin
    +          EndPos:=p+4;
    +          Result:=copy(Result,1,p-1)+'<'+copy(Result,EndPos,length(Result));
    +        end else
    +        if (p+2<Length(Result)) and (Result[p+1]='g') and (Result[p+2]='t') and (Result[p+3]=';') then begin
    +          EndPos:=p+4;
    +          Result:=copy(Result,1,p-1)+'>'+copy(Result,EndPos,length(Result));
    +        end else
    +        if (p+3<Length(Result)) and (Result[p+1]='a') and (Result[p+2]='m') and (Result[p+3]='p') and (Result[p+4]=';') then begin
    +          EndPos:=p+5;
    +        Result:=copy(Result,1,p-1)+'&'+copy(Result,EndPos,length(Result));
           end;
           inc(p);
         end else
    @@ -518,6 +511,7 @@
       Alignment := taLeftJustify;
       Font.Color := clInfoText;
       BorderSpacing.Around := 4;
    +  ShowAccelChar := False;  //don't underline after &
     end;
     
     function TSimpleHTMLControl.GetURL: string;
    
    idehelpmanager.diff (2,165 bytes)

Activities

Martin Friebe

2012-11-16 00:38

manager   ~0063855

Maybe GTK specific, does not happen on win (even after inserting an ampersand in the string).

Do you use TourboPowerIProDsgn (html hints, with links in the hint)?

Benito van der Zander

2012-11-16 22:24

reporter   ~0063867

>Do you use TourboPowerIProDsgn (html hints, with links in the hint)?

No



And it seems the bugtracker killed my example, the string is supposed to contain the html entity like in the source of this issue, not a single <.

Bart Broersma

2012-11-16 23:23

developer   ~0063868

Last edited: 2012-11-16 23:42

Happens in CodeTools also.
Behaviour on my side is not exactly as described by original reporter.
Observed behaviour (on my side) is same for CodeTools in IDE and Debugger.

In the constant definitions in the code below remove any spaces, I put them there to fool Mantis

const
  S = '& l<a';
  S2 = '& lt <a';
  S3 = '& lt <a;';
begin
  writeln(S,S2,S3);

Hoover:
S -> &l<a (NO underlining of <)
S1 -> ≤<a (underlined < followed by <a)
S2 -> ≤<a (underlined < followed by <a)

See also attached screenshot from IDE

Lazarus 1.1 r39272 FPC 2.6.0 i386-win32-win32/win64
I only have packages installed that come with "make clean all"

2012-11-16 23:36

 

strangehint.png (6,795 bytes)
strangehint.png (6,795 bytes)

Martin Friebe

2012-11-17 00:58

manager   ~0063870

On Windows too. Only none html hints are affected. (Adjusted issue title)

Bart Broersma

2012-11-17 17:43

developer   ~0063875

As a side note: it also does incorrect "translation" to HTML: &lt is not a HTML entity (it misses the closing semicolon (;) )

Bart Broersma

2012-11-18 12:22

developer   ~0063883

Last edited: 2012-11-18 12:24

It seems it does this only for (again: remove any spaces between "&" and next character, I put them there to fool Mantis):
& lt -> underlined "<"
& gt -> underlined ">"
& amp -> "&" and the next char will be underlined

Other html entities like "& euml;" or "& micro;" do not get "translated".

Bart Broersma

2012-11-18 17:39

developer   ~0063888

Problem is in ide\idehelpmanager.pas:
function HTMLToCaption(const s: string; MaxLines: integer): string;

It doesn't handle the html entities correctly.
It also adds an extra & in case it detects an ampersand, which makes sense for TSimpleHTMLControl, but not for e.g. TScrollableHTMLControl

- I fixed handling html entities.
- I removed the extra &
- In constructor TSimpleHTMLControl.Create(AOwner: TComponent) I added:
  ShowAccelChar := False; //don't underline after &

See attached idehelpmanager.diff

2012-11-18 17:40

 

idehelpmanager.diff (2,165 bytes)
Index: ide/idehelpmanager.pas
===================================================================
--- ide/idehelpmanager.pas	(revision 39272)
+++ ide/idehelpmanager.pas	(working copy)
@@ -460,24 +460,17 @@
         Result:=copy(Result,1,p-1)+copy(Result,EndPos,length(Result));
     end else if Result[p]='&' then begin
       // special chars: &lt; &gt; &amp;
-      if (Result[p+1]='l') and (Result[p+2]='t') then begin
-        EndPos:=p+3;
-        if (EndPos<length(Result)) and (Result[EndPos]=';') then
-          inc(EndPos);
-        Result:=copy(Result,1,p-1)+'<'+copy(Result,EndPos,length(Result));
-      end else
-      if (Result[p+1]='g') and (Result[p+2]='t') then begin
-        EndPos:=p+3;
-        if (EndPos<length(Result)) and (Result[EndPos]=';') then
-          inc(EndPos);
-        Result:=copy(Result,1,p-1)+'>'+copy(Result,EndPos,length(Result));
-      end else
-      if (Result[p+1]='a') and (Result[p+2]='m') and (Result[p+3]='p') then begin
-        EndPos:=p+4;
-        if (EndPos<length(Result)) and (Result[EndPos]=';') then
-          inc(EndPos);
-        // double '&' to prevent underlining
-        Result:=copy(Result,1,p-1)+'&&'+copy(Result,EndPos,length(Result));
+        if (p+2<Length(Result)) and (Result[p+1]='l') and (Result[p+2]='t') and (Result[p+3]=';') then begin
+          EndPos:=p+4;
+          Result:=copy(Result,1,p-1)+'<'+copy(Result,EndPos,length(Result));
+        end else
+        if (p+2<Length(Result)) and (Result[p+1]='g') and (Result[p+2]='t') and (Result[p+3]=';') then begin
+          EndPos:=p+4;
+          Result:=copy(Result,1,p-1)+'>'+copy(Result,EndPos,length(Result));
+        end else
+        if (p+3<Length(Result)) and (Result[p+1]='a') and (Result[p+2]='m') and (Result[p+3]='p') and (Result[p+4]=';') then begin
+          EndPos:=p+5;
+        Result:=copy(Result,1,p-1)+'&'+copy(Result,EndPos,length(Result));
       end;
       inc(p);
     end else
@@ -518,6 +511,7 @@
   Alignment := taLeftJustify;
   Font.Color := clInfoText;
   BorderSpacing.Around := 4;
+  ShowAccelChar := False;  //don't underline after &
 end;
 
 function TSimpleHTMLControl.GetURL: string;
idehelpmanager.diff (2,165 bytes)

Bart Broersma

2012-11-18 17:41

developer   ~0063889

Target 1.2.0 for review of patch.

Martin Friebe

2012-11-25 22:57

manager   ~0064034

Patch looks correct to me. Thanks.

Applied.

Issue History

Date Modified Username Field Change
2012-11-14 16:15 Benito van der Zander New Issue
2012-11-14 16:15 Benito van der Zander Widgetset => GTK 2
2012-11-16 00:38 Martin Friebe Note Added: 0063855
2012-11-16 22:24 Benito van der Zander Note Added: 0063867
2012-11-16 23:23 Bart Broersma Note Added: 0063868
2012-11-16 23:24 Bart Broersma Note Edited: 0063868
2012-11-16 23:25 Bart Broersma LazTarget => -
2012-11-16 23:25 Bart Broersma Status new => confirmed
2012-11-16 23:26 Bart Broersma Note Edited: 0063868
2012-11-16 23:27 Bart Broersma Note Edited: 0063868
2012-11-16 23:31 Bart Broersma Note Edited: 0063868
2012-11-16 23:35 Bart Broersma Note Edited: 0063868
2012-11-16 23:35 Bart Broersma Note Edited: 0063868
2012-11-16 23:36 Bart Broersma File Added: strangehint.png
2012-11-16 23:42 Bart Broersma Note Edited: 0063868
2012-11-17 00:58 Martin Friebe Widgetset GTK 2 => GTK 2, Win32/Win64
2012-11-17 00:58 Martin Friebe Note Added: 0063870
2012-11-17 00:58 Martin Friebe Summary debugger parses html entities in mouse over hints => IDE hint paint html entities (&..) incorrect
2012-11-17 00:58 Martin Friebe Steps to Reproduce Updated
2012-11-17 17:43 Bart Broersma Note Added: 0063875
2012-11-18 12:22 Bart Broersma Note Added: 0063883
2012-11-18 12:24 Bart Broersma Note Edited: 0063883
2012-11-18 17:39 Bart Broersma Note Added: 0063888
2012-11-18 17:40 Bart Broersma File Added: idehelpmanager.diff
2012-11-18 17:41 Bart Broersma LazTarget - => 1.2
2012-11-18 17:41 Bart Broersma Widgetset GTK 2, Win32/Win64 => GTK, GTK 2, Win32/Win64, WinCE, Carbon
2012-11-18 17:41 Bart Broersma Note Added: 0063889
2012-11-18 17:41 Bart Broersma Reproducibility have not tried => always
2012-11-18 17:41 Bart Broersma Target Version => 1.2.0
2012-11-25 22:55 Martin Friebe Status confirmed => assigned
2012-11-25 22:55 Martin Friebe Assigned To => Martin Friebe
2012-11-25 22:57 Martin Friebe Fixed in Revision => 39374
2012-11-25 22:57 Martin Friebe Status assigned => resolved
2012-11-25 22:57 Martin Friebe Fixed in Version => 1.1 (SVN)
2012-11-25 22:57 Martin Friebe Resolution open => fixed
2012-11-25 22:57 Martin Friebe Note Added: 0064034