Skip to content
GitLab
    • GitLab: the DevOps platform
    • Explore GitLab
    • Install GitLab
    • How GitLab compares
    • Get started
    • GitLab docs
    • GitLab Learn
  • Pricing
  • Talk to an expert
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
    • Switch to GitLab Next
    Projects Groups Topics Snippets
  • Register
  • Sign in
  • Lazarus Lazarus
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
    • Locked files
  • Issues 2,095
    • Issues 2,095
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 14
    • Merge requests 14
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test cases
  • Deployments
    • Deployments
    • Releases
  • Packages and registries
    • Packages and registries
    • Container Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • External wiki
    • External wiki
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • FPC
  • LazarusLazarus
  • LazarusLazarus
  • Issues
  • #31732
Closed
Open
Issue created Apr 28, 2017 by FPC Admin account@fpc_adminOwner

LHelp can't handle javascript:helppopup links, but here is solution for this problem ("patch")

Original Reporter info from Mantis: SunyD @soner-a
  • Reporter name: Soner

Description:

I made changes in lhelp.pas to handle links like "javascript:helppopup('xzy.htm')" or "javascript:popuplink('xzy.htm')". 
Read the comments in following text. (Copy it in one editor with pascal-syntax-higlighter)
---------
Comment out code here: Lazarus\components\chmhelp\lhelp\ChmDataProvider.pas
function TIpChmDataProvider.CanHandle(const URL: string): Boolean;
var
  HelpFile: String;
  Reader: TChmReader = nil;
begin
  Result := True;
  if Pos('Java', URL) =1  then Result := False;
  if  (fChm.ObjectExists(StripInPageLink(url), Reader)= 0)
  and (fChm.ObjectExists(StripInPageLink(BuildUrl(fCurrentPath,Url)), Reader) = 0) then Result := False;
  //DebugLn('CanHandle ',Url,' = ', Result);
  //if not Result then if fChm.ObjectExists(BuildURL('', URL)) > 0 Then result := true;

  {XXX soner: comment outed, because dead code nothing, moved to chmcontentprovider.pas ... XXXXXXX
  if (Pos('javascript:helppopup(''', LowerCase(URL)) = 1) then begin
    HelpFile := Copy(URL, 23, Length(URL) - (23-1));
    HelpFile := Copy(HelpFile, 1, Pos('''', HelpFile)-1);
    //DebugLn('HelpFile = ', HelpFile);
  end;
  XXX END of comment out by Soner XXXXXXXXXXXXXXXXXXXX }
  if (not Result) and (Pos('#', URL) = 1) then Result := True;
end;           
Add code here:Lazarus\components\chmhelp\lhelp\chmcontentprovider.pas
procedure TChmContentProvider.IpHtmlPanelHotClick(Sender: TObject);
var
  HelpFile: String; //soner from ChmDataProvider.pas
  aPos: integer;    //soner added
begin
 // Soner moved from ChmDataProvider.pas to here ...
 // chm-links looks like: mk:@MSITStore:D:\LazPortable\docs\chm\iPro.chm::/html/lh3zs3.htm
 if (Pos('javascript:helppopup(''', LowerCase(fHtml.HotURL)) = 1)or
    (Pos('javascript:popuplink(''', LowerCase(fHtml.HotURL)) = 1) //soner added
   then begin
   HelpFile := Copy(fHtml.HotURL, 23, Length(fHtml.HotURL) - (23-1));
   HelpFile := Copy(HelpFile, 1, Pos('''', HelpFile)-1);

   if (Pos('/',HelpFile)=0)and(Pos('.chm:',HelpFile)=0) then begin //looks like?: 'xyz.htm'
     aPos:=LastDelimiter('/', fHtml.CurURL);
     if aPos>0 then HelpFile:=Copy(fHtml.CurURL,1,aPos)+HelpFile;
   end
   else if (Pos('.chm:',HelpFile)=0) then begin  //looks like?: 'folder/xyz.htm' or '/folder/xyz.htm'
     if HelpFile[1]<>'/' then HelpFile:='/'+HelpFile;
     aPos:=LastDelimiter(':', fHtml.CurURL);
     if aPos>0 then HelpFile:=Copy(fHtml.CurURL,1,aPos)+HelpFile;
   end;
   DoLoadUri(HelpFile); //open it in current iphtmlpanel.
   { Soner: Normally it should be the HelpPopupForm opened, but HelpPopupForm is empty, it is
     something to do.}
 end
 else
 // end of Soner's changes
  OpenURL(fHtml.HotURL);
end; 

Steps to reproduce:

  1. open the included chm-file in lhelp

  2. klick on links with title:
    Hierarchy

  3. the link will be opened in extern browser.

  4. Now make the my changes to lhelp make 2. again.
    now the link will be opened in lhelp.

Mantis conversion info:

  • Mantis ID: 31732
  • OS: Windows
  • Build: Svn-Rev. 54278
  • Platform: i386-win
  • Version: 1.6.4
  • Fixed in version: 1.9 (SVN)
  • Fixed in revision: 54872 (#f9266d01)
  • Target version: 1.8
Assignee
Assign to
Time tracking