Make the doctype handling work the way it should.

This commit is contained in:
Michael[tm] Smith 2012-03-14 19:38:18 +09:00
parent 9412ef6eba
commit c331917c31
2 changed files with 10 additions and 9 deletions

View file

@ -119,9 +119,8 @@ int TY_(HTMLVersion)(TidyDocImpl* doc)
!cfgBool(doc, TidyHtmlOut); !cfgBool(doc, TidyHtmlOut);
Bool html4 = dtmode == TidyDoctypeStrict || dtmode == TidyDoctypeLoose || VERS_FROM40 & dtver; Bool html4 = dtmode == TidyDoctypeStrict || dtmode == TidyDoctypeLoose || VERS_FROM40 & dtver;
// don't mess with <!doctype html> if (xhtml && dtver == VERS_UNKNOWN) return XH50;
if (HT50) return HT50; if (dtver == VERS_UNKNOWN) return HT50;
if (XH50) return XH50;
for (i = 0; W3C_Doctypes[i].name; ++i) for (i = 0; W3C_Doctypes[i].name; ++i)
{ {
@ -1552,6 +1551,8 @@ Bool TY_(SetXHTMLDocType)( TidyDocImpl* doc )
TidyDoctypeModes dtmode = (TidyDoctypeModes)cfg(doc, TidyDoctypeMode); TidyDoctypeModes dtmode = (TidyDoctypeModes)cfg(doc, TidyDoctypeMode);
ctmbstr pub = "PUBLIC"; ctmbstr pub = "PUBLIC";
ctmbstr sys = "SYSTEM"; ctmbstr sys = "SYSTEM";
Bool xhtml = (cfgBool(doc, TidyXmlOut) || doc->lexer->isvoyager) &&
!cfgBool(doc, TidyHtmlOut);
lexer->versionEmitted = TY_(ApparentVersion)( doc ); lexer->versionEmitted = TY_(ApparentVersion)( doc );
@ -1595,7 +1596,11 @@ Bool TY_(SetXHTMLDocType)( TidyDocImpl* doc )
TY_(RepairAttrValue)(doc, doctype, sys, ""); TY_(RepairAttrValue)(doc, doctype, sys, "");
break; break;
case TidyDoctypeAuto: case TidyDoctypeAuto:
if (lexer->versions & XH11 && lexer->doctype == XH11) if (xhtml && lexer->doctype == VERS_UNKNOWN) {
lexer->versionEmitted = XH50;
return yes;
}
else if (lexer->versions & XH11 && lexer->doctype == XH11)
{ {
if (!TY_(GetAttrByName)(doctype, sys)) if (!TY_(GetAttrByName)(doctype, sys))
TY_(RepairAttrValue)(doc, doctype, sys, GetSIFromVers(XH11)); TY_(RepairAttrValue)(doc, doctype, sys, GetSIFromVers(XH11));
@ -1633,10 +1638,6 @@ Bool TY_(SetXHTMLDocType)( TidyDocImpl* doc )
TY_(RepairAttrValue)(doc, doctype, sys, GetSIFromVers(X10T)); TY_(RepairAttrValue)(doc, doctype, sys, GetSIFromVers(X10T));
lexer->versionEmitted = X10T; lexer->versionEmitted = X10T;
} }
else if (lexer->versions & XH50)
{
lexer->versionEmitted = XH50;
}
else else
{ {
if (doctype) if (doctype)

View file

@ -194,7 +194,7 @@ typedef enum
/* special flag */ /* special flag */
#define VERS_XML 65536u #define VERS_XML 65536u
/* "HTML5" */ /* HTML5 */
#define HT50 131072u #define HT50 131072u
#define XH50 262144u #define XH50 262144u