Browse Source

--- Merging r16443 into '.':
U packages/fcl-xml/src/xmlwrite.pp
--- Merging r16766 into '.':
U packages/fcl-xml/src/xmlread.pp

# revisions: 16443,16766
------------------------------------------------------------------------
r16443 | michael | 2010-11-26 13:44:23 +0100 (Fri, 26 Nov 2010) | 1 line
Changed paths:
M /trunk/packages/fcl-xml/src/xmlwrite.pp

* Patch from Graeme Geldenhuys to check for XMLDocument before typecasting it
------------------------------------------------------------------------
------------------------------------------------------------------------
r16766 | sergei | 2011-01-15 08:35:40 +0100 (Sat, 15 Jan 2011) | 2 lines
Changed paths:
M /trunk/packages/fcl-xml/src/xmlread.pp

* xmlread.pp, fixed condition that was causing an infinite loop in case when a malformed xml contained a null character within whitespace (to be exact, within parts processed by SkipS procedure). Great thanks to alexs75 for finding and supplying such xml file :)

------------------------------------------------------------------------

git-svn-id: branches/fixes_2_4@16785 -

marco 14 years ago
parent
commit
f3147ae1d6
2 changed files with 11 additions and 8 deletions
  1. 1 1
      packages/fcl-xml/src/xmlread.pp
  2. 10 7
      packages/fcl-xml/src/xmlwrite.pp

+ 1 - 1
packages/fcl-xml/src/xmlread.pp

@@ -1208,7 +1208,7 @@ begin
       Result := True;
     until False;
     FSource.FBuf := p;
-  until (p^ <> #0) or (not FSource.Reload);
+  until (FSource.FBuf < FSource.FBufEnd) or (not FSource.Reload);
   if (not Result) and Required then
     FatalError('Expected whitespace');
 end;

+ 10 - 7
packages/fcl-xml/src/xmlwrite.pp

@@ -681,14 +681,17 @@ begin
   wrtStr('?>');
 
   // TODO: now handled as a regular PI, remove this?
-  if Length(TXMLDocument(node).StylesheetType) > 0 then
+  if node is TXMLDocument then
   begin
-    wrtStr(FLineBreak);
-    wrtStr('<?xml-stylesheet type="');
-    wrtStr(TXMLDocument(node).StylesheetType);
-    wrtStr('" href="');
-    wrtStr(TXMLDocument(node).StylesheetHRef);
-    wrtStr('"?>');
+    if Length(TXMLDocument(node).StylesheetType) > 0 then
+    begin
+      wrtStr(FLineBreak);
+      wrtStr('<?xml-stylesheet type="');
+      wrtStr(TXMLDocument(node).StylesheetType);
+      wrtStr('" href="');
+      wrtStr(TXMLDocument(node).StylesheetHRef);
+      wrtStr('"?>');
+    end;
   end;
 
   child := node.FirstChild;