Add a TidyInfo message each time an unquoted attribute is found. However,
refer to #412 for discussion before merging this.
This commit is contained in:
Jim Derry 2017-09-22 19:01:31 -04:00
parent cf6f47ca1c
commit c579d5b62c
4 changed files with 15 additions and 15 deletions

1
include/tidyenum.h Normal file → Executable file
View file

@ -220,6 +220,7 @@ extern "C" {
FN(MISSING_ENDTAG_FOR) \
FN(MISSING_IMAGEMAP) \
FN(MISSING_QUOTEMARK) \
FN(MISSING_QUOTEMARK_OPEN) \
FN(MISSING_SEMICOLON_NCR) \
FN(MISSING_SEMICOLON) \
FN(MISSING_STARTTAG) \

1
src/language_en.h Normal file → Executable file
View file

@ -1877,6 +1877,7 @@ static languageDefinition language_en = { whichPluralForm_en, {
{ MISSING_ENDTAG_FOR, 0, "missing </%s>" },
{ MISSING_IMAGEMAP, 0, "%s should use client-side image map" },
{ MISSING_QUOTEMARK, 0, "%s attribute with missing trailing quote mark" },
{ MISSING_QUOTEMARK_OPEN, 0, "value for attribute \"%s\" missing quote marks" },
{ MISSING_SEMICOLON_NCR, 0, "numeric character reference \"%s\" doesn't end in ';'" },
{ MISSING_SEMICOLON, 0, "entity \"%s\" doesn't end in ';'" },
{ MISSING_STARTTAG, 0, "missing <%s>" },

11
src/lexer.c Normal file → Executable file
View file

@ -3621,8 +3621,9 @@ static Node *ParsePhp( TidyDocImpl* doc )
}
/* consumes the '>' terminating start tags */
/* @TODO: float the errors back to the calling method */
static tmbstr ParseAttribute( TidyDocImpl* doc, Bool *isempty,
Node **asp, Node **php)
Node **asp, Node **php )
{
Lexer* lexer = doc->lexer;
int start, len = 0;
@ -3984,8 +3985,6 @@ static tmbstr ParseValue( TidyDocImpl* doc, ctmbstr name,
{
uint q = c;
TY_(ReportAttrError)( doc, lexer->token, NULL, UNEXPECTED_QUOTEMARK );
/* handle <input onclick=s("btn1")> and <a title=foo""">...</a> */
/* this doesn't handle <a title=foo"/> which browsers treat as */
/* 'foo"/' nor <a title=foo" /> which browser treat as 'foo"' */
@ -4156,7 +4155,7 @@ static tmbstr ParseValue( TidyDocImpl* doc, ctmbstr name,
value = NULL;
/* note delimiter if given */
*pdelim = (delim ? delim : '"');
*pdelim = delim;
return value;
}
@ -4273,11 +4272,13 @@ static AttVal* ParseAttrs( TidyDocImpl* doc, Bool *isempty )
(cfgBool(doc, TidyXmlTags) && IsValidXMLAttrName(attribute))))
{
av = TY_(NewAttribute)(doc);
av->delim = delim;
av->delim = delim ? delim : '"';
av->attribute = attribute;
av->value = value;
av->dict = TY_(FindAttribute)( doc, av );
AddAttrToList( &list, av );
if ( !delim && value )
TY_(ReportAttrError)( doc, lexer->token, av, MISSING_QUOTEMARK_OPEN);
}
else
{

View file

@ -309,6 +309,7 @@ static struct _dispatchTable {
{ MISSING_ENDTAG_FOR, TidyWarning, formatStandard },
{ MISSING_IMAGEMAP, TidyWarning, formatAttributeReport },
{ MISSING_QUOTEMARK, TidyWarning, formatAttributeReport },
{ MISSING_QUOTEMARK_OPEN, TidyInfo, formatAttributeReport },
{ MISSING_SEMICOLON_NCR, TidyWarning, formatStandard },
{ MISSING_SEMICOLON, TidyWarning, formatStandard },
{ MISSING_STARTTAG, TidyWarning, formatStandard },
@ -531,7 +532,10 @@ TidyMessageImpl *formatAttributeReport(TidyDocImpl* doc, Node *element, Node *no
switch (code)
{
case BACKSLASH_IN_URI:
case MISSING_QUOTEMARK_OPEN:
return TY_(tidyMessageCreateWithNode)(doc, node, code, level, name );
case BACKSLASH_IN_URI:
case ESCAPED_ILLEGAL_URI:
case FIXED_BACKSLASH:
case ID_NAME_MISMATCH:
@ -546,14 +550,12 @@ TidyMessageImpl *formatAttributeReport(TidyDocImpl* doc, Node *element, Node *no
case UNEXPECTED_QUOTEMARK:
case WHITE_IN_URI:
return TY_(tidyMessageCreateWithNode)(doc, node, code, level, tagdesc );
break;
case ATTRIBUTE_IS_NOT_ALLOWED:
case JOINING_ATTRIBUTE:
case MISSING_ATTR_VALUE:
case PROPRIETARY_ATTRIBUTE:
return TY_(tidyMessageCreateWithNode)(doc, node, code, level, tagdesc, name );
break;
case ATTRIBUTE_VALUE_REPLACED:
case BAD_ATTRIBUTE_VALUE:
@ -561,30 +563,25 @@ TidyMessageImpl *formatAttributeReport(TidyDocImpl* doc, Node *element, Node *no
case INSERTING_AUTO_ATTRIBUTE:
case INVALID_ATTRIBUTE:
return TY_(tidyMessageCreateWithNode)(doc, node, code, level, tagdesc, name, value );
break;
case MISMATCHED_ATTRIBUTE_ERROR:
case MISMATCHED_ATTRIBUTE_WARN:
return TY_(tidyMessageCreateWithNode)(doc, node, code, level, tagdesc, name, HTMLVersion(doc));
break;
case ANCHOR_NOT_UNIQUE:
case ATTR_VALUE_NOT_LCASE:
case PROPRIETARY_ATTR_VALUE:
case XML_ID_SYNTAX:
return TY_(tidyMessageCreateWithNode)(doc, node, code, level, tagdesc, value );
break;
case REPEATED_ATTRIBUTE:
return TY_(tidyMessageCreateWithNode)(doc, node, code, level, tagdesc, value, name );
break;
case UNEXPECTED_END_OF_FILE_ATTR:
/* on end of file adjust reported position to end of input */
doc->lexer->lines = doc->docIn->curline;
doc->lexer->columns = doc->docIn->curcol;
return TY_(tidyMessageCreateWithLexer)(doc, code, level, tagdesc );
break;
}
return NULL;
@ -1095,8 +1092,8 @@ void TY_(Dialogue)(TidyDocImpl* doc, uint code, ...)
{
if ( dialogueDispatchTable[i].code == code )
{
TidyMessageImpl *message;
TidyReportLevel level = dialogueDispatchTable[i].level;
TidyMessageImpl *message;
va_start(args, code);
message = formatDialogue( doc, code, level, args );
va_end(args);