Browse Source

* Fixed handling of ']' character in CDATA sections, when it is not starting a ']]>' delimiter it must be output as-is. Mantis #23794.

git-svn-id: trunk@23551 -
sergei 12 years ago
parent
commit
f5a8f69517
1 changed files with 10 additions and 5 deletions
  1. 10 5
      packages/fcl-xml/src/xmlwrite.pp

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

@@ -384,12 +384,17 @@ end;
 procedure CDSectSpecialCharCallback(Sender: TXMLWriter; const s: DOMString;
 procedure CDSectSpecialCharCallback(Sender: TXMLWriter; const s: DOMString;
   var idx: Integer);
   var idx: Integer);
 begin
 begin
-  if (idx <= Length(s)-2) and (s[idx+1] = ']') and (s[idx+2] = '>') then
+  if s[idx]=']' then
   begin
   begin
-    Sender.wrtStr(']]]]><![CDATA[>');
-    Inc(idx, 2);
-    // TODO: emit warning 'cdata-section-splitted'
-  end
+    if (idx <= Length(s)-2) and (s[idx+1] = ']') and (s[idx+2] = '>') then
+    begin
+      Sender.wrtStr(']]]]><![CDATA[>');
+      Inc(idx, 2);
+      // TODO: emit warning 'cdata-section-splitted'
+    end
+    else
+      Sender.wrtChr(']');
+  end  
   else
   else
     raise EConvertError.Create('Illegal character');
     raise EConvertError.Create('Illegal character');
 end;
 end;