Skip to content

Commit

Permalink
Fixed: XHTML file is opened without any content #161
Browse files Browse the repository at this point in the history
- did not recognize end of xhtml script tag <script ... />
  • Loading branch information
BerndGabriel committed Sep 20, 2016
1 parent a794197 commit 322c8a4
Show file tree
Hide file tree
Showing 5 changed files with 128 additions and 88 deletions.
38 changes: 19 additions & 19 deletions source/FramBrwz.pas
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ interface
TGetPostRequestExEvent = procedure(Sender: TObject; IsGet: boolean; const URL, Query, EncType, Referer: ThtString;
Reload: boolean; var NewURL: ThtString; var DocType: ThtmlFileType; var Stream: TStream) of object;

TbrFormSubmitEvent = procedure(Sender: TObject; Viewer: ThtmlViewer;
TbrFormSubmitEvent = procedure(Sender: TObject; Viewer: THtmlViewer;
const Action, Target, EncType, Method: ThtString; Results: ThtStringList; var Handled: boolean) of object;

TbrFrameSet = class;
TbrSubFrameSet = class;

TbrFrame = class(TViewerFrameBase) {TbrFrame holds a ThtmlViewer or TbrSubFrameSet}
TbrFrame = class(TViewerFrameBase) {TbrFrame holds a THtmlViewer or TbrSubFrameSet}
private
URLBase: ThtString;
TheStream: TStream;
Expand Down Expand Up @@ -133,7 +133,7 @@ TFrameBrowser = class(TFVBase)
public
constructor Create(AOwner: TComponent); override;
constructor CreateCopy(Owner: TComponent; Source: TViewerBase); override;
function GetViewerUrlBase(Viewer: ThtmlViewer): ThtString;
function GetViewerUrlBase(Viewer: THtmlViewer): ThtString;
procedure GetPostQuery(const URL, Query, EncType: ThtString; IsGet: boolean);
procedure HotSpotClick(Sender: TObject; const AnURL: ThtString; var Handled: boolean); override;
procedure Load(const SRC: ThtString); override;
Expand Down Expand Up @@ -386,7 +386,7 @@ procedure TbrFrame.frLoadFromBrzFile(const URL, Dest, Query, EncType, Referer: T
HS, S, S1, OldTitle, OldName, OldBase: ThtString;
OldFormData: TFreeList;
SameName: boolean;
OldViewer: ThtmlViewer;
OldViewer: THtmlViewer;
OldFrameSet: TbrSubFrameSet;
Upper, Lower, FrameFile: boolean;
Item: TFrameBase;
Expand Down Expand Up @@ -606,12 +606,12 @@ function ConvDosToHTML(const Name: ThtString): ThtString;
procedure TbrFrame.URLExpandName(Sender: TObject; const SRC: ThtString; var Rslt: ThtString);
var
S: ThtString;
Viewer: ThtmlViewer;
Viewer: THtmlViewer;
begin
S := ConvDosToHTML(SRC);
if not IsFullUrl(S) then
begin
Viewer := Sender as ThtmlViewer;
Viewer := Sender as THtmlViewer;
if Pos('//', SRC) = 1 then
S := 'http:' + S
else if Viewer.Base <> '' then
Expand Down Expand Up @@ -877,8 +877,8 @@ procedure TFrameBrowser.LoadURLInternal(const URL, Dest, Query, EncType, Referer
if (OldFrameSet.Viewers.Count = 1) then
begin
Tmp := OldFrameSet.Viewers[0];
if Tmp is ThtmlViewer then
OldPos := ThtmlViewer(Tmp).Position;
if Tmp is THtmlViewer then
OldPos := THtmlViewer(Tmp).Position;
end;
OldFrameSet.UnloadFiles;
CurbrFrameSet.Visible := True;
Expand All @@ -903,8 +903,8 @@ procedure TFrameBrowser.LoadURLInternal(const URL, Dest, Query, EncType, Referer
if (CurbrFrameSet.Viewers.Count = 1) then
begin
Tmp := CurbrFrameSet.Viewers[0];
if Tmp is ThtmlViewer then
OldPos := ThtmlViewer(Tmp).Position;
if Tmp is THtmlViewer then
OldPos := THtmlViewer(Tmp).Position;
end;
PostRequest(Self, IsGet, S, Query, EncType, Referer, Reload, S1, StreamType, Stream);
if not Assigned(Stream) then
Expand Down Expand Up @@ -963,7 +963,7 @@ procedure TFrameBrowser.HotSpotClick(Sender: TObject; const AnURL: ThtString; va
if Handled then
Exit;

Viewer := Sender as ThtmlViewer;
Viewer := Sender as THtmlViewer;
Target := GetViewerTarget(Viewer);
FLinkAttributes.Text := Viewer.LinkAttributes.Text;
FLinkText := Viewer.LinkText;
Expand Down Expand Up @@ -1038,11 +1038,11 @@ procedure TFrameBrowser.HotSpotClick(Sender: TObject; const AnURL: ThtString; va
procedure TFrameBrowser.HotSpotCovered(Sender: TObject; const SRC: ThtString);
var
S, Dest, FullUrl: ThtString;
Viewer: ThtmlViewer;
Viewer: THtmlViewer;
begin
if Assigned(OnHotSpotTargetCovered) then
begin
Viewer := Sender as ThtmlViewer;
Viewer := Sender as THtmlViewer;
SplitDest(SRC, S, Dest);
S := ConvDosToHTML(S); {convert DOS names}
if IsFullURL(S) or (Src = '') then
Expand All @@ -1056,7 +1056,7 @@ procedure TFrameBrowser.HotSpotCovered(Sender: TObject; const SRC: ThtString);
end;
FLinkText := Viewer.LinkText;
FLinkAttributes.Text := Viewer.LinkAttributes.Text;
OnHotSpotTargetCovered(Sender, (Sender as ThtmlViewer).Target, FullUrl + Dest);
OnHotSpotTargetCovered(Sender, (Sender as THtmlViewer).Target, FullUrl + Dest);
end;
end;

Expand All @@ -1074,7 +1074,7 @@ procedure TFrameBrowser.DoFormSubmitEvent(Sender: TObject; const Action, Target,
S, Dest, Query: ThtString;
FrameTarget: TFrameBase;
I: integer;
Viewer: ThtmlViewer;
Viewer: THtmlViewer;
UserHandled, IsGet: boolean;

function AssembleQuery: ThtString;
Expand Down Expand Up @@ -1139,7 +1139,7 @@ procedure TFrameBrowser.DoFormSubmitEvent(Sender: TObject; const Action, Target,
try
{see if the application wants to handle this event}
UserHandled := false;
Viewer := (Sender as ThtmlViewer);
Viewer := (Sender as THtmlViewer);
if Assigned(FOnFormSubmit) then
FOnFormSubmit(Self, Viewer, Action, Target, EncType, Method, Results, UserHandled);
if not UserHandled then
Expand Down Expand Up @@ -1209,7 +1209,7 @@ procedure TFrameBrowser.DoURLRequest(Sender: TObject; const SRC: ThtString; var

{----------------TFrameBrowser.GetViewerUrlBase}

function TFrameBrowser.GetViewerUrlBase(Viewer: ThtmlViewer): ThtString;
function TFrameBrowser.GetViewerUrlBase(Viewer: THtmlViewer): ThtString;
var
Frame: TbrFrame;
begin
Expand All @@ -1235,13 +1235,13 @@ procedure TFrameBrowser.CheckVisitedLinks;
var
I, J, K: integer;
S, S1: ThtString;
Viewer: ThtmlViewer;
Viewer: THtmlViewer;
begin
if VisitedMaxCount = 0 then
Exit;
for K := 0 to CurbrFrameSet.Viewers.Count - 1 do
begin
Viewer := ThtmlViewer(CurbrFrameSet.Viewers[K]);
Viewer := THtmlViewer(CurbrFrameSet.Viewers[K]);
for I := 0 to Visited.Count - 1 do
begin
S := Visited[I];
Expand Down
27 changes: 20 additions & 7 deletions source/HtmlSymb.pas
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
Version 11.5
Copyright (c) 2014 by HtmlViewer Team
Version 11.7
Copyright (c) 2014-2016 by HtmlViewer Team
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
Expand Down Expand Up @@ -39,9 +39,16 @@ interface
TElemSymb = (
OtherChar, CommandSy, StringSy {was TextSy}, EolSy, EofSy,

{ doc type tags }
XmlSy, DocTypeSy,

{ html elements }

HtmlSy, HeadSy,
HtmlEndSy, HeadEndSy,

{ frame set elements }

FrameSetSy, FrameSetEndSy,
FrameSy,
NoFramesSy, NoFramesEndSy,
Expand All @@ -65,9 +72,9 @@ interface

ImageSy,
PanelSy,
IFrameSy, IFrameEndSy,
IFrameSy, IFrameEndSy,
ProgressSy, ProgressEndSy,
MeterSy, MeterEndSy,
MeterSy, MeterEndSy,

MapSy, MapEndSy,
AreaSy,
Expand Down Expand Up @@ -163,6 +170,7 @@ interface
ContentSy,
CoordsSy,
DisabledSy,
EncodingSy,
EncTypeSy,
FaceSy,
FrameAttrSy,
Expand Down Expand Up @@ -228,6 +236,7 @@ interface
UseMapSy,
VAlignSy,
ValueSy,
VersionSy,
VLinkSy,
VSpaceSy,
WidthSy,
Expand Down Expand Up @@ -647,7 +656,10 @@ procedure InitEntities;

procedure InitElements;
const
ElementDefinitions: array[1..102] of TResWord = (
ElementDefinitions: array[1..104] of TResWord = (
(Name: '?XML'; Symbol: XmlSy; EndSym: CommandSy),
(Name: '!DOCTYPE'; Symbol: DocTypeSy; EndSym: CommandSy),
{HTML}
(Name: 'HTML'; Symbol: HtmlSy; EndSym: HtmlEndSy),
(Name: 'TITLE'; Symbol: TitleElemSy; EndSym: TitleEndSy),
(Name: 'BODY'; Symbol: BodySy; EndSym: BodyEndSy),
Expand Down Expand Up @@ -754,7 +766,6 @@ procedure InitElements;
(Name: 'TIME'; Symbol: TimeSy; EndSym: TimeEndSy),
(Name: 'PROGRESS'; Symbol: ProgressSy; EndSym: ProgressEndSy),
(Name: 'METER'; Symbol: MeterSy; EndSym: MeterEndSy));

var
I: Integer;
P: PResWord;
Expand Down Expand Up @@ -789,7 +800,7 @@ procedure InitElements;

procedure InitAttributes;
const
AttribDefinitions: array[1..93] of TSymbolRec = (
AttribDefinitions: array[1..95] of TSymbolRec = (
(Name: 'ACTION'; Value: ActionSy),
(Name: 'ACTIVE'; Value: ActiveSy),
(Name: 'ALIGN'; Value: AlignSy),
Expand All @@ -814,6 +825,7 @@ procedure InitAttributes;
(Name: 'CONTENT'; Value: ContentSy),
(Name: 'COORDS'; Value: CoordsSy),
(Name: 'DISABLED'; Value: DisabledSy),
(Name: 'ENCODING'; Value: EncodingSy),
(Name: 'ENCTYPE'; Value: EncTypeSy),
(Name: 'FACE'; Value: FaceSy),
(Name: 'FRAME'; Value: FrameAttrSy),
Expand Down Expand Up @@ -879,6 +891,7 @@ procedure InitAttributes;
(Name: 'USEMAP'; Value: UseMapSy),
(Name: 'VALIGN'; Value: VAlignSy),
(Name: 'VALUE'; Value: ValueSy),
(Name: 'VERSION'; Value: VersionSy),
(Name: 'VLINK'; Value: VLinkSy),
(Name: 'VSPACE'; Value: VSpaceSy),
(Name: 'WIDTH'; Value: WidthSy),
Expand Down
Loading

0 comments on commit 322c8a4

Please sign in to comment.