HtmlViewer icon indicating copy to clipboard operation
HtmlViewer copied to clipboard

Bug in TbrFrame.URLExpandName

Open TommySlokky opened this issue 7 years ago • 0 comments

If you have a https site that uses //someimage.gif the images will not work in the current browser

The current code

procedure TbrFrame.URLExpandName(Sender: TObject; const SRC: ThtString; var Rslt: ThtString);
var
  S: ThtString;
  Viewer: THtmlViewer;
begin
  S := ConvDosToHTML(SRC);
  if not IsFullUrl(S) then
  begin
    Viewer := Sender as THtmlViewer;
    if Pos('//', SRC) = 1 then
       S := 'http:' + S

This code even returns empty "Rslt"

...

In my case - I use OnGetPostRequestEx and OnGetStreamImage where I myself handle grabbing content over https, so for me the soultion is simply to replace the above code with

procedure TbrFrame.URLExpandName(Sender: TObject; const SRC: ThtString; var Rslt: ThtString);
var
  S: ThtString;
  Viewer: THtmlViewer;
begin
  S := ConvDosToHTML(SRC);
  if not IsFullUrl(S) then
  begin
    Viewer := Sender as THtmlViewer;
    if Pos('//', SRC) = 1 then
       Rslt := SRC

However - otherwise I would suggest not hard coding http anywhere. HTTPs is more and more prevalent . I am still learning the code behind HTMLViewer (thanks), so my fix is only a suggestion.

TommySlokky avatar Nov 17 '17 23:11 TommySlokky