Explorar o código

* Handle xml/xhtml style empty tags by emitting a pair of StartElement/EndElement events with
correct tag name.

Slightly modified patch from Marco van de Voort, resolves #13409.

git-svn-id: trunk@13047 -

sergei %!s(int64=16) %!d(string=hai) anos
pai
achega
b9ad8e3755
Modificáronse 1 ficheiros con 11 adicións e 2 borrados
  1. 11 2
      packages/fcl-xml/src/sax_html.pp

+ 11 - 2
packages/fcl-xml/src/sax_html.pp

@@ -380,11 +380,20 @@ begin
       if Length(TokenText) > 0 then
       begin
         Attr := nil;
-        if TokenText[1] = '/' then
+        if TokenText[Length(fTokenText)]='/' then  // handle xml/xhtml style empty tag
+        begin
+          setlength(fTokenText,length(fTokenText)-1);
+          // Do NOT combine to a single line, as Attr is an output value!
+          TagName := SplitTagString(TokenText, Attr);
+          DoStartElement('', TagName, '', Attr);
+          DoEndElement('', TagName, '');
+        end
+        else if TokenText[1] = '/' then
         begin
           DoEndElement('',
             SplitTagString(Copy(TokenText, 2, Length(TokenText)), Attr), '');
-        end else if TokenText[1] <> '!' then
+        end
+        else if TokenText[1] <> '!' then
         begin
           // Do NOT combine to a single line, as Attr is an output value!
           TagName := SplitTagString(TokenText, Attr);