report missing href & rel for link elements

This commit is contained in:
Michael[tm] Smith 2011-11-20 20:58:35 +09:00
parent 585769b5ba
commit 34305a13d1
5 changed files with 15 additions and 13 deletions

View file

@ -537,6 +537,7 @@ typedef enum
TidyAttr_HTTP_EQUIV, /**< HTTP_EQUIV= */
TidyAttr_ID, /**< ID= */
TidyAttr_ISMAP, /**< ISMAP= */
TidyAttr_ITEMPROP, /**< ITEMPROP= */
TidyAttr_LABEL, /**< LABEL= */
TidyAttr_LANG, /**< LANG= */
TidyAttr_LANGUAGE, /**< LANGUAGE= */

View file

@ -4740,6 +4740,7 @@ const AttrVersion TY_(W3CAttrsFor_LINK)[] =
{ TidyAttr_HREF, HT20|HT32|H40T|H41T|X10T|H40F|H41F|X10F|H40S|H41S|X10S|XH11|XB10|HT50|XH50 },
{ TidyAttr_HREFLANG, xxxx|xxxx|H40T|H41T|X10T|H40F|H41F|X10F|H40S|H41S|X10S|XH11|XB10|HT50|XH50 },
{ TidyAttr_ID, xxxx|xxxx|H40T|H41T|X10T|H40F|H41F|X10F|H40S|H41S|X10S|XH11|XB10|HT50|XH50 },
{ TidyAttr_ITEMPROP, xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|HT50|XH50 },
{ TidyAttr_LANG, xxxx|xxxx|H40T|H41T|X10T|H40F|H41F|X10F|H40S|H41S|X10S|xxxx|xxxx|HT50|XH50 },
{ TidyAttr_MEDIA, xxxx|xxxx|H40T|H41T|X10T|H40F|H41F|X10F|H40S|H41S|X10S|XH11|XB10|HT50|XH50 },
{ TidyAttr_METHODS, HT20|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx },

View file

@ -158,6 +158,7 @@ static const Attribute attribute_defs [] =
{ TidyAttr_HTTP_EQUIV, "http-equiv", CH_PCDATA }, /* META */
{ TidyAttr_ID, "id", CH_IDDEF },
{ TidyAttr_ISMAP, "ismap", CH_BOOL }, /* IMG */
{ TidyAttr_ITEMPROP, "itemprop", CH_PCDATA },
{ TidyAttr_LABEL, "label", CH_PCDATA }, /* OPT, OPTGROUP */
{ TidyAttr_LANG, "lang", CH_LANG },
{ TidyAttr_LANGUAGE, "language", CH_PCDATA }, /* SCRIPT */

View file

@ -223,6 +223,7 @@ uint TY_(NodeAttributeVersions)( Node* node, TidyAttrId id );
#define attrIsHTTP_EQUIV(av) AttrIsId( av, TidyAttr_HTTP_EQUIV )
#define attrIsID(av) AttrIsId( av, TidyAttr_ID )
#define attrIsISMAP(av) AttrIsId( av, TidyAttr_ISMAP )
#define attrIsITEMPROP(av) AttrIsId( av, TidyAttr_ITEMPROP )
#define attrIsLABEL(av) AttrIsId( av, TidyAttr_LABEL )
#define attrIsLANG(av) AttrIsId( av, TidyAttr_LANG )
#define attrIsLANGUAGE(av) AttrIsId( av, TidyAttr_LANGUAGE )

View file

@ -786,23 +786,21 @@ void CheckTABLE( TidyDocImpl* doc, Node *node )
}
}
/* add missing type attribute when appropriate */
/* report missing href attribute; report missing rel attribute */
void CheckLINK( TidyDocImpl* doc, Node *node )
{
AttVal *rel = TY_(AttrGetById)(node, TidyAttr_REL);
Bool HasHref = TY_(AttrGetById)(node, TidyAttr_HREF) != NULL;
Bool HasRel = TY_(AttrGetById)(node, TidyAttr_REL) != NULL;
Bool HasItemprop = TY_(AttrGetById)(node, TidyAttr_ITEMPROP) != NULL;
TY_(CheckAttributes)( doc, node );
/* todo: <link rel="alternate stylesheet"> */
if (AttrValueIs(rel, "stylesheet"))
if (!HasHref)
{
AttVal *type = TY_(AttrGetById)(node, TidyAttr_TYPE);
if (!type)
{
TY_(AddAttribute)( doc, node, "type", "text/css" );
type = TY_(AttrGetById)(node, TidyAttr_TYPE);
TY_(ReportAttrError)( doc, node, type, INSERTING_ATTRIBUTE );
TY_(ReportMissingAttr)( doc, node, "href" );
}
if (!HasItemprop && !HasRel)
{
TY_(ReportMissingAttr)( doc, node, "rel" );
}
}