mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-14 10:29:24 +02:00
+ After reaching EOF condition, clear FNodeData[0] slot
* For entities in attributes, place entity name to FQName rather than to FValueStr. * Allow doc to stay unassigned. git-svn-id: trunk@18104 -
This commit is contained in:
parent
45771d0a70
commit
57ba5f956e
@ -2898,7 +2898,7 @@ begin
|
|||||||
begin
|
begin
|
||||||
case curr^.FNodeType of
|
case curr^.FNodeType of
|
||||||
ntText: result.InternalAppend(doc.CreateTextNode(curr^.FValueStr));
|
ntText: result.InternalAppend(doc.CreateTextNode(curr^.FValueStr));
|
||||||
ntEntityReference: result.InternalAppend(doc.CreateEntityReference(curr^.FValueStr));
|
ntEntityReference: result.InternalAppend(doc.CreateEntityReference(curr^.FQName^.Key));
|
||||||
end;
|
end;
|
||||||
curr := curr^.FNext;
|
curr := curr^.FNext;
|
||||||
end;
|
end;
|
||||||
|
@ -314,6 +314,7 @@ type
|
|||||||
FCanonical: Boolean;
|
FCanonical: Boolean;
|
||||||
FMaxChars: Cardinal;
|
FMaxChars: Cardinal;
|
||||||
|
|
||||||
|
procedure SetEOFState;
|
||||||
procedure SkipQuote(out Delim: WideChar; required: Boolean = True);
|
procedure SkipQuote(out Delim: WideChar; required: Boolean = True);
|
||||||
procedure Initialize(ASource: TXMLCharSource);
|
procedure Initialize(ASource: TXMLCharSource);
|
||||||
procedure NSPrepare;
|
procedure NSPrepare;
|
||||||
@ -1286,6 +1287,8 @@ begin
|
|||||||
FIDMap.Free;
|
FIDMap.Free;
|
||||||
FForwardRefs.Free;
|
FForwardRefs.Free;
|
||||||
FAttrChunks.Free;
|
FAttrChunks.Free;
|
||||||
|
if doc = nil then
|
||||||
|
FNameTable.Free;
|
||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1569,6 +1572,7 @@ var
|
|||||||
start: TObject;
|
start: TObject;
|
||||||
curr: PNodeData;
|
curr: PNodeData;
|
||||||
StartPos: Integer;
|
StartPos: Integer;
|
||||||
|
entName: PHashItem;
|
||||||
begin
|
begin
|
||||||
SkipQuote(Delim);
|
SkipQuote(Delim);
|
||||||
curr := AttrData;
|
curr := AttrData;
|
||||||
@ -1584,6 +1588,7 @@ begin
|
|||||||
if ParseRef(FValue) or ResolvePredefined then
|
if ParseRef(FValue) or ResolvePredefined then
|
||||||
Continue;
|
Continue;
|
||||||
|
|
||||||
|
entName := FNameTable.FindOrAdd(FName.Buffer, FName.Length);
|
||||||
ent := EntityCheck(True);
|
ent := EntityCheck(True);
|
||||||
if ((ent = nil) or (not FExpandEntities)) and (FSource.FEntity = start) then
|
if ((ent = nil) or (not FExpandEntities)) and (FSource.FEntity = start) then
|
||||||
begin
|
begin
|
||||||
@ -1596,11 +1601,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
curr := AllocAttributeValueChunk(curr);
|
curr := AllocAttributeValueChunk(curr);
|
||||||
curr^.FNodeType := ntEntityReference;
|
curr^.FNodeType := ntEntityReference;
|
||||||
// TODO: this probably should be placed to 'name'
|
curr^.FQName := entName;
|
||||||
if ent = nil then
|
|
||||||
SetString(curr^.FValueStr, FName.Buffer, FName.Length)
|
|
||||||
else
|
|
||||||
curr^.FValueStr := ent.FName;
|
|
||||||
end;
|
end;
|
||||||
StartPos := FValue.Length;
|
StartPos := FValue.Length;
|
||||||
if Assigned(ent) then
|
if Assigned(ent) then
|
||||||
@ -2548,7 +2549,8 @@ begin
|
|||||||
if FSource.FBuf^ = '?' then
|
if FSource.FBuf^ = '?' then
|
||||||
begin
|
begin
|
||||||
ParsePI;
|
ParsePI;
|
||||||
doc.AppendChild(CreatePINode);
|
if Assigned(doc) then
|
||||||
|
doc.AppendChild(CreatePINode);
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
@ -2634,7 +2636,10 @@ var
|
|||||||
Ent: TDOMEntityEx;
|
Ent: TDOMEntityEx;
|
||||||
DoctypeNode: TDOMDocumentType;
|
DoctypeNode: TDOMDocumentType;
|
||||||
begin
|
begin
|
||||||
DoctypeNode := doc.DocType;
|
if Assigned(doc) then
|
||||||
|
DoctypeNode := doc.DocType
|
||||||
|
else
|
||||||
|
Exit;
|
||||||
if DoctypeNode = nil then
|
if DoctypeNode = nil then
|
||||||
Exit;
|
Exit;
|
||||||
Ent := TDOMEntityEx(DocTypeNode.Entities.GetNamedItem(AEntity.FName));
|
Ent := TDOMEntityEx(DocTypeNode.Entities.GetNamedItem(AEntity.FName));
|
||||||
@ -2657,6 +2662,14 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure TXMLTextReader.SetEOFState;
|
||||||
|
begin
|
||||||
|
FCurrNode := @FNodeStack[0];
|
||||||
|
Finalize(FCurrNode^);
|
||||||
|
FillChar(FCurrNode^, sizeof(TNodeData), 0);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TXMLTextReader.ValidateCurrentNode;
|
procedure TXMLTextReader.ValidateCurrentNode;
|
||||||
var
|
var
|
||||||
ElDef: TElementDecl;
|
ElDef: TElementDecl;
|
||||||
@ -3018,6 +3031,7 @@ begin
|
|||||||
Exit;
|
Exit;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
xtEOF: SetEofState;
|
||||||
end;
|
end;
|
||||||
Result := tok <> xtEOF;
|
Result := tok <> xtEOF;
|
||||||
end;
|
end;
|
||||||
@ -3191,6 +3205,7 @@ begin
|
|||||||
xtPI: ParsePI;
|
xtPI: ParsePI;
|
||||||
xtDoctype: ParseDoctypeDecl;
|
xtDoctype: ParseDoctypeDecl;
|
||||||
xtComment: ParseComment(False);
|
xtComment: ParseComment(False);
|
||||||
|
xtEOF: SetEofState;
|
||||||
end;
|
end;
|
||||||
Result := tok <> xtEOF;
|
Result := tok <> xtEOF;
|
||||||
end;
|
end;
|
||||||
@ -3677,9 +3692,12 @@ begin
|
|||||||
SetLength(FNodeStack, AIndex * 2 + 2);
|
SetLength(FNodeStack, AIndex * 2 + 2);
|
||||||
|
|
||||||
Result := @FNodeStack[AIndex];
|
Result := @FNodeStack[AIndex];
|
||||||
|
Result^.FNext := nil;
|
||||||
Result^.FPrefix := nil;
|
Result^.FPrefix := nil;
|
||||||
Result^.FNsUri := nil;
|
Result^.FNsUri := nil;
|
||||||
Result^.FIDEntry := nil;
|
Result^.FIDEntry := nil;
|
||||||
|
Result^.FValueStart := nil;
|
||||||
|
Result^.FValueLength := 0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TXMLTextReader.AllocAttributeValueChunk(APrev: PNodeData): PNodeData;
|
function TXMLTextReader.AllocAttributeValueChunk(APrev: PNodeData): PNodeData;
|
||||||
|
Loading…
Reference in New Issue
Block a user