Conversion to XML

Conversion to XML (with -asxml flag) doesn't result in correct XML, if
source file contain scripts. 

For ex. source:

<BODY>
<SCRIPT LANGUAGE="JavaScript">
 document.write("test1<BR>");
 document.write("test2<BR>");
</SCRIPT>
</BODY>

after tiding won't be loaded by XML parser, because <BR> tag won't be
closed, i.e converted to <BR/>.

Solution: escape scripts tags with <!CDATA[[ section, I provide a possible
fix below:

File - pprint.c:

/*
	Revised by Alexei Veremenko:
	Changes marked by //!!! [alexv]
	Escape scripts with CDATA section when XmlOut = yes
*/

void PPrintTag(Lexer *lexer, Out *fout, uint mode, uint indent, Node *node)
{
    char c, *p;

    AddC('<', linelen++);

    if (node->type == EndTag)
        AddC('/', linelen++);

    for (p = node->element; (c = *p); ++p)
        AddC(FoldCase(c, UpperCaseTags), linelen++);

    PPrintAttrs(fout, indent, lexer, node, node->attributes);

    if ((XmlOut == yes || lexer->isvoyager) &&
            (node->type == StartEndTag || node->tag->model & CM_EMPTY ))
    {
        AddC(' ', linelen++);   /* compatibility hack */
        AddC('/', linelen++);
    }

    AddC('>', linelen++);;

    if (node->type != StartEndTag && !(mode & PREFORMATTED))
    {
        if (indent + linelen >= wraplen)
            WrapLine(fout, indent);

        if (indent + linelen < wraplen)
        {
            /*
             avoid wrapping after inline start tag unless
             it or its parent follows a space and its not
             an empty tag (e.g. IMG) followed by </a>
            */
            if (AfterSpace(lexer, node))
            {
                if (!(mode & NOWRAP) &&
                    !((node->tag->model & CM_EMPTY) && 
                      node->next == null &&
                      node->parent->tag == tag_a))
                {
                    wraphere = linelen;
                }
            }
        }
        else
            PCondFlushLine(fout, indent);
    }

	//!!! [alexv]
	//!!! Escape scripts with CDATA section if the output is XML
	if (XmlOut == yes && node->tag == tag_script)
	{
		// Print <![CDATA[
        AddC('<', linelen++);
        AddC('!', linelen++);
        AddC('[', linelen++);
        AddC('C', linelen++);
        AddC('D', linelen++);
        AddC('A', linelen++);
        AddC('T', linelen++);
        AddC('A', linelen++);
        AddC('[', linelen++);
	}
	//!!! [end of alexv]
}

void PPrintEndTag(Out *fout, uint mode, uint indent, Node *node)
{
	char c, *p;

	//!!! [alexv]
	//!!! Escape scripts with CDATA section if the output is XML
	if (XmlOut == yes && node->tag == tag_script)
	{
		// Print <![CDATA[
        AddC(']', linelen++);
        AddC(']', linelen++);
        AddC('>', linelen++);
	}
	//!!! [end of alexv]
    
   /*
     Netscape ignores SGML standard by not ignoring a
     line break before </A> or </U> etc. To avoid rendering 
     this as an underlined space, I disable line wrapping
     before inline end tags by the #if 0 ... #endif
   */
#if 0
    if (indent + linelen < wraplen && !(mode & NOWRAP))
        wraphere = linelen;
#endif

    AddC('<', linelen++);
    AddC('/', linelen++);

    for (p = node->element; (c = *p); ++p)
        AddC(FoldCase(c, UpperCaseTags), linelen++);

    AddC('>', linelen++);
}

begin 600 winmail.dat
M>)\^(@42`0:0"``$```````!``$``0>0!@`(````XP0```````#G``$(@`<`
M&````$E032Y-:6-R;W-O9G0@36%I;"Y.;W1E`#$(`06``P`.````T`<%``4`
M%@`C`#8`!0!5`0$@@`,`#@```-`'!0`%`!8`)``$``4`)`$!"8`!`"$````S
M.#<R,D0V-4(R,C)$-#$Q.4(U0C`P,3`T0C@X041$-0#^!@$$@`$`$@```$-O
M;G9E<G-I;VX@=&\@6$U,`#H&`0V`!``"`````@`"``$#D`8`5`L``"T````+
M``(``0```$``.0``22._P+:_`1X`<``!````$@```$-O;G9E<G-I;VX@=&\@
M6$U,`````@%Q``$````6`````;^VP2!_92UR6B*R$=2;6P`02XBMU0``'@`Q
M0`$````)````04Q%6$595D4``````P`:0``````>`#!``0````D```!!3$58
M15E610`````#`!E```````(!"1`!````P08``+T&``"($```3%I&=4Z$JW0#
M``H`<F-P9S$R-1<`4`$'"V!N#A`P-#F=`?<@`J0#XP(`8V@*P*AS970!T#0`
M`"H"X3IA!X`@!Q,"@`<3($,<65("@P!0$'9P<G$J-Q#7,!(F?0J!=6.C`%`+
M`W5L;@(@90NF^Q+P`B!V!)``D`(@`S`/!`0S,Q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W*L?G]_AW4;E857
MG?^CKZ2V_:I-G^G?!IMN/U1O_U5_5H]7GUBO6;\)SW!_$)\O;\$96:FT%8$`
M%7`````#`-X_@E$```L``H`((`8``````,````````!&``````.%````````
M`P`#@`@@!@``````P````````$8`````$(4````````#``2`""`&``````#`
M````````1@````!2A0``\!,``!X`!8`((`8``````,````````!&`````%2%
M```!````!````#@N-0`+``^`""`&``````#`````````1@`````&A0``````
M``,`!H`((`8``````,````````!&``````&%````````"P`'@`@@!@``````
MP````````$8`````#H4````````#``B`""`&``````#`````````1@`````1
MA0````````,`"8`((`8``````,````````!&`````!B%````````'@`*@`@@
M!@``````P````````$8`````-H4```$````!`````````!X`"X`((`8`````
M`,````````!&`````#>%```!`````0`````````>``R`""`&``````#`````
M````1@`````XA0```0````$`````````"P`-@`L@!@``````P````````$8`
M`````(@````````+``Z`"R`&``````#`````````1@`````%B`````````,`
M\3\)!````P#]/^,$```#`"8```````,`-@```````P"`$/____\"`4<``0``
M`"X```!C/5)5.V$](#MP/59$23ML/4580TA!3D=%+3`P,#4P-3$X,S4U-%HM
M,S8R-C8````>`#A``0````D```!!3$5815E610`````>`#E``0````D```!!
M3$5815E610````!```<P$/\@O\"VOP%```@P=C+(Q,"VOP$>`#T``0````$`
M````````'@`=#@$````2````0V]N=F5R<VEO;B!T;R!834P````>`#40`0``
M`#(````\0C,P.$(V,C8S,$4U1#,Q,4%$03,P,#`P-C)!,3=&0D(T-3<P0S9`
M15A#2$%.1T4^````"P`I```````+`",```````,`!A#&),MU`P`'$#L(```#
M`!`0``````,`$1`!````'@`($`$```!E````0T].5D524TE/3E1/6$U,*%=)
M5$@M05-834Q&3$%'*41/15-.5%)%4U5,5$E.0T]24D5#5%A-3"Q)1E-/55)#
M149)3$5#3TY404E.4T-225!44T9/4D584T]54D-%.CQ"3T19/``````"`7\`
M`0```#(````\0C,P.$(V,C8S,$4U1#,Q,4%$03,P,#`P-C)!,3=&0D(T-3<P
10S9`15A#2$%.1T4^````IRL=
`
end

Received on Friday, 5 May 2000 15:01:28 UTC