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_ENDTAG_FOR) \
FN(MISSING_IMAGEMAP) \ FN(MISSING_IMAGEMAP) \
FN(MISSING_QUOTEMARK) \ FN(MISSING_QUOTEMARK) \
FN(MISSING_QUOTEMARK_OPEN) \
FN(MISSING_SEMICOLON_NCR) \ FN(MISSING_SEMICOLON_NCR) \
FN(MISSING_SEMICOLON) \ FN(MISSING_SEMICOLON) \
FN(MISSING_STARTTAG) \ 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_ENDTAG_FOR, 0, "missing </%s>" },
{ MISSING_IMAGEMAP, 0, "%s should use client-side image map" }, { MISSING_IMAGEMAP, 0, "%s should use client-side image map" },
{ MISSING_QUOTEMARK, 0, "%s attribute with missing trailing quote mark" }, { 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_NCR, 0, "numeric character reference \"%s\" doesn't end in ';'" },
{ MISSING_SEMICOLON, 0, "entity \"%s\" doesn't end in ';'" }, { MISSING_SEMICOLON, 0, "entity \"%s\" doesn't end in ';'" },
{ MISSING_STARTTAG, 0, "missing <%s>" }, { MISSING_STARTTAG, 0, "missing <%s>" },

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

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

View file

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