* Fix bug ID (patch from Martok) to fix script parsing

git-svn-id: trunk@37863 -
This commit is contained in:
michael 2017-12-29 13:25:49 +00:00
parent 7b46b3d35e
commit d997db7fa7
4 changed files with 34 additions and 6 deletions

2
.gitattributes vendored
View File

@ -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/buildfclxml.lpi 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/src/README.txt svneol=native#text/plain
packages/fcl-xml/src/dom.pp svneol=native#text/plain

View File

@ -0,0 +1,6 @@
<html><head>
<script>
document.write('<title>Banner<\/title>');
</script>
</head>
</html>

View 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.

View File

@ -553,16 +553,17 @@ begin
AutoClose(TagName);
namePush(TagName);
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
begin
NewContext := scScript;
FScriptEndTag := '</' + HTMLElementProps[FStack[FNesting-1]].Name;
FScriptEndMatchPos := 1;
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;
if Assigned(Attr) then
Attr.Free;
@ -574,8 +575,8 @@ begin
scScript:
begin
DoCharacters(PSAXChar(TokenText), 0, Length(TokenText));
DoEndElement('', HTMLElementProps[FStack[FNesting-1]].Name, '');
namePop;
DoEndElement('', Copy(FScriptEndTag, 3), '');
NamePop;
FScriptEndTag := '';
end;
end;