Skip to content
GitLab
  • Menu
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
    • Switch to GitLab Next
  • Sign in / Register
  • Lazarus Lazarus
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 2,108
    • Issues 2,108
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 9
    • Merge requests 9
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • Code review
    • Insights
    • Issue
    • Repository
  • External wiki
    • External wiki
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • FPC
  • LazarusLazarus
  • LazarusLazarus
  • Issues
  • #36523
Closed
Open
Issue created Jan 06, 2020 by FPC Admin account@fpc_adminOwner

LHelp bug: titles with a '&' alone, cause a "range check error".

Original Reporter info from Mantis: devEric69
  • Reporter name: devEric69

Description:

- compile lHelp.
- open user.chm avec lHelp.
==> there's a "Range chack error" abort because a title is called Keybord & Mouse.

Steps to reproduce:

In ChmSpecialParser.pas, line 67, ther's thisfunction FixEscapedHTML(AText: string): string;

Below, in the "Additional information" memo, I've pasted this corrected function (patch), so that it distinguishes now a '&' alone (as in the title of user.chm '6.4.2 Keybord & Mouse"), from a character belonging to the HTML grammar like ' ', or '&lt', etc., etc.

Additional information:

function FixEscapedHTML(AText: string): string;
var
  i, iPosAmpersand, iLenAText: Integer;
  bFoundClosureSemiColon: Boolean;
  ampstr: string; sTemp: string;
  ws: widestring;
  entity: widechar;
begin
  Result := '';
  i := 1;
  iLenAText:= Length(AText);
  while i <= iLenAText do begin
    if AText[i]='&' then begin
      iPosAmpersand:= i;
      ampStr := '';
      inc(i);
      while (i <= iLenAText) and (AText[i] <> ';') do begin
				ampStr := ampStr + AText[i];
        inc(i);
      end;
      //is there a Char ';', closing a possible HTML entity like '&{#x}~~~{~~};'?
      bFoundClosureSemiColon:= False;
      if (i > iLenAText) then begin
        if (AText[i-1] = ';') then
          bFoundClosureSemiColon := True
      end
			else begin
        if (AText[i] = ';') then
        	bFoundClosureSemiColon := True;
      end;
      if bFoundClosureSemiColon then begin	//so, if it's a possible HTML encoded character like "&xxx;" ...
        ws := UTF8Encode(ampStr);
        if ResolveHTMLEntityReference(ws, entity) then
          Result := Result + UnicodeToUTF8(cardinal(entity))
        else
          Result := Result + '?';
      end
      else begin	//so, if it's not an HTML entity ie it's only an ampersand alone
        sTemp := RightStr(AText, iLenAText - (iPosAmpersand-1));
				Result := Result + sTemp;
			end
    end
    else
      Result := Result + AText[i];
    inc(i);
  end;
end;            

Mantis conversion info:

  • Mantis ID: 36523
  • OS: Ubuntu
  • OS Build: 18.04
  • Platform: Linux
  • Version: 2.0.4
  • Fixed in revision: r62510 (#55a41430)
  • Monitored by: » devEric69 (devEric69)
Assignee
Assign to
Time tracking