mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-12-11 12:10:43 +01:00
* Fix bug ID #32389 (patch from Martok) to fix script parsing
git-svn-id: trunk@37863 -
This commit is contained in:
parent
7b46b3d35e
commit
d997db7fa7
2
.gitattributes
vendored
2
.gitattributes
vendored
@ -3458,6 +3458,8 @@ packages/fcl-xml/Makefile.fpc svneol=native#text/plain
|
|||||||
packages/fcl-xml/Makefile.fpc.fpcmake svneol=native#text/plain
|
packages/fcl-xml/Makefile.fpc.fpcmake svneol=native#text/plain
|
||||||
packages/fcl-xml/buildfclxml.lpi svneol=native#text/plain
|
packages/fcl-xml/buildfclxml.lpi svneol=native#text/plain
|
||||||
packages/fcl-xml/buildfclxml.pp svneol=native#text/plain
|
packages/fcl-xml/buildfclxml.pp svneol=native#text/plain
|
||||||
|
packages/fcl-xml/examples/test.html svneol=native#text/html
|
||||||
|
packages/fcl-xml/examples/testhtml.pp svneol=native#text/plain
|
||||||
packages/fcl-xml/fpmake.pp svneol=native#text/plain
|
packages/fcl-xml/fpmake.pp svneol=native#text/plain
|
||||||
packages/fcl-xml/src/README.txt svneol=native#text/plain
|
packages/fcl-xml/src/README.txt svneol=native#text/plain
|
||||||
packages/fcl-xml/src/dom.pp svneol=native#text/plain
|
packages/fcl-xml/src/dom.pp svneol=native#text/plain
|
||||||
|
|||||||
6
packages/fcl-xml/examples/test.html
Normal file
6
packages/fcl-xml/examples/test.html
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<html><head>
|
||||||
|
<script>
|
||||||
|
document.write('<title>Banner<\/title>');
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
</html>
|
||||||
19
packages/fcl-xml/examples/testhtml.pp
Normal file
19
packages/fcl-xml/examples/testhtml.pp
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
program testhtml;
|
||||||
|
{
|
||||||
|
simple demo to demonstrate rewriting a HTML file
|
||||||
|
}
|
||||||
|
uses sysutils, dom_html,sax_html, XMLWrite;
|
||||||
|
|
||||||
|
Var
|
||||||
|
H : THTMLDocument;
|
||||||
|
|
||||||
|
begin
|
||||||
|
if ParamCount<>2 then
|
||||||
|
begin
|
||||||
|
Writeln('Usage: ',ExtractFileName(Paramstr(0)),' inputfile outputfile');
|
||||||
|
Halt(1);
|
||||||
|
end;
|
||||||
|
ReadHTMLFile(H,ParamStr(1));
|
||||||
|
WriteXMLFile(H,Paramstr(2));
|
||||||
|
end.
|
||||||
|
|
||||||
@ -553,16 +553,17 @@ begin
|
|||||||
AutoClose(TagName);
|
AutoClose(TagName);
|
||||||
namePush(TagName);
|
namePush(TagName);
|
||||||
DoStartElement('', TagName, '', Attr);
|
DoStartElement('', TagName, '', Attr);
|
||||||
if not (efSubelementContent in HTMLElementProps[FStack[FNesting-1]].Flags) then begin
|
|
||||||
DoEndElement('', TagName, '');
|
|
||||||
NamePop;
|
|
||||||
end;
|
|
||||||
if FStack[FNesting-1] in [etScript,etStyle] then
|
if FStack[FNesting-1] in [etScript,etStyle] then
|
||||||
begin
|
begin
|
||||||
NewContext := scScript;
|
NewContext := scScript;
|
||||||
FScriptEndTag := '</' + HTMLElementProps[FStack[FNesting-1]].Name;
|
FScriptEndTag := '</' + HTMLElementProps[FStack[FNesting-1]].Name;
|
||||||
FScriptEndMatchPos := 1;
|
FScriptEndMatchPos := 1;
|
||||||
end;
|
end;
|
||||||
|
if (efSubcontent*HTMLElementProps[FStack[FNesting-1]].Flags=[]) then begin
|
||||||
|
// do not push empty elements, don't wait for AutoClose
|
||||||
|
DoEndElement('', TagName, '');
|
||||||
|
NamePop;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
if Assigned(Attr) then
|
if Assigned(Attr) then
|
||||||
Attr.Free;
|
Attr.Free;
|
||||||
@ -574,8 +575,8 @@ begin
|
|||||||
scScript:
|
scScript:
|
||||||
begin
|
begin
|
||||||
DoCharacters(PSAXChar(TokenText), 0, Length(TokenText));
|
DoCharacters(PSAXChar(TokenText), 0, Length(TokenText));
|
||||||
DoEndElement('', HTMLElementProps[FStack[FNesting-1]].Name, '');
|
DoEndElement('', Copy(FScriptEndTag, 3), '');
|
||||||
namePop;
|
NamePop;
|
||||||
FScriptEndTag := '';
|
FScriptEndTag := '';
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user