diff --git a/components/wiki/lazwiki/wikiparser.pas b/components/wiki/lazwiki/wikiparser.pas index 746abd5333..b1a3a5f3ef 100644 --- a/components/wiki/lazwiki/wikiparser.pas +++ b/components/wiki/lazwiki/wikiparser.pas @@ -335,6 +335,7 @@ var // normalize link to get the page, e.g. convert spaces to underscores function WikiInternalLinkToPage(Link: string): string; +function WikiIsExternalLink(Link: string): boolean; function GetWikiPageID(doc: TDOMNode): string; function GetWikiPageID(s: TStream): string; @@ -1560,6 +1561,25 @@ begin end; end; +function WikiIsExternalLink(Link: string): boolean; +// check if Link starts with a scheme http:// +var + p: PChar; +begin + Result:=false; + if Link='' then exit; + p:=PChar(Link); + while p^ in ['a'..'z','A'..'Z'] do inc(p); + if p=PChar(Link) then exit; + if p^<>':' then exit; + inc(p); + if p^<>'/' then exit; + inc(p); + if p^<>'/' then exit; + inc(p); + Result:=true; +end; + function GetWikiPageID(doc: TDOMNode): string; var Node: TDOMNode; diff --git a/components/wiki/test/wikisearchmain.pas b/components/wiki/test/wikisearchmain.pas index 22e434c6d7..6c28763ff5 100644 --- a/components/wiki/test/wikisearchmain.pas +++ b/components/wiki/test/wikisearchmain.pas @@ -26,10 +26,10 @@ interface uses Classes, SysUtils, math, FileUtil, LazLogger, LazUTF8, LazFileUtils, laz2_DOM, - Forms, Controls, Graphics, Dialogs, StdCtrls, ExtCtrls, ComCtrls, + Forms, Controls, Graphics, Dialogs, StdCtrls, ExtCtrls, ComCtrls, LCLIntf, IpHtml, Ipfilebroker, IpMsg, CodeToolManager, CodeCache, - WikiHelpManager, WikiSearchOptions; + WikiHelpManager, WikiSearchOptions, WikiParser; type @@ -258,6 +258,12 @@ begin //Target := TIpHtmlNodeAREA(HotNode).Target; end; debugln(['TWikiSearchDemoForm.ResultsIpHtmlPanelHotClick href=',href]); + if WikiIsExternalLink(HRef) then begin + // open external page + OpenURL(HRef); + exit; + end; + // open page in PageIpHtmlPanel ms:=TMemoryStream.Create; try