示例#1
0
void TY_(ReportEncodingWarning)(TidyDocImpl* doc, uint code, uint encoding)
{
    switch(code)
    {
    case ENCODING_MISMATCH:
        messageLexer(doc, TidyWarning, code, tidyLocalizedString(code),
                     TY_(CharEncodingName)(doc->docIn->encoding),
                     TY_(CharEncodingName)(encoding));
        doc->badChars |= BC_ENCODING_MISMATCH;
        break;
    }
}
示例#2
0
/* Generates the string indicating the source document position for which
** Tidy has generated a message.
*/
static char* ReportPosition(TidyDocImpl* doc, int line, int col, char* buf, size_t count)
{
    *buf = 0;

    /* Change formatting to be parsable by GNU Emacs */
    if ( cfgBool(doc, TidyEmacs) && cfgStr(doc, TidyEmacsFile) )
        TY_(tmbsnprintf)(buf, count, "%s:%d:%d: ", 
                         cfgStr(doc, TidyEmacsFile), line, col);
    else /* traditional format */
        TY_(tmbsnprintf)(buf, count, tidyLocalizedString(LINE_COLUMN_STRING), line, col);
    return buf + TY_(tmbstrlen)( buf );
}
示例#3
0
void TY_(ReportNotice)(TidyDocImpl* doc, Node *element, Node *node, uint code)
{
    Node* rpt = ( element ? element : node );
    ctmbstr fmt = tidyLocalizedString(code);
    char nodedesc[256] = { 0 };
    char elemdesc[256] = { 0 };

    assert( fmt != NULL );

    TagToString(node, nodedesc, sizeof(nodedesc));

    switch (code)
    {
    case TRIM_EMPTY_ELEMENT:
        TagToString(element, elemdesc, sizeof(nodedesc));
        messageNode(doc, TidyWarning, code, element, fmt, elemdesc);
        break;

    case REPLACING_ELEMENT:
        TagToString(element, elemdesc, sizeof(elemdesc));
        messageNode(doc, TidyWarning, code, rpt, fmt, elemdesc, nodedesc);
        break;
    }
}
示例#4
0
void TY_(ReportAccessError)( TidyDocImpl* doc, Node* node, uint code )
{
    ctmbstr fmt = tidyLocalizedString(code);
    doc->badAccess |= BA_WAI;
    messageNode( doc, TidyAccess, code, node, "%s", fmt );
}
示例#5
0
void TY_(DisplayHTMLTableAlgorithm)( TidyDocImpl* doc )
{
    tidy_out(doc, "%s", tidyLocalizedString(TEXT_HTML_T_ALGORITHM));
}
示例#6
0
void TY_(ReportAttrError)(TidyDocImpl* doc, Node *node, AttVal *av, uint code)
{
    char const *name = "NULL", *value = "NULL";
    char tagdesc[64];
    ctmbstr fmt = tidyLocalizedString(code);
    uint version;
    ctmbstr extra_string;

    assert( fmt != NULL );

    TagToString(node, tagdesc, sizeof(tagdesc));

    if (av)
    {
        if (av->attribute)
            name = av->attribute;
        if (av->value)
            value = av->value;
    }

    switch (code)
    {
    case UNKNOWN_ATTRIBUTE:
    case INSERTING_ATTRIBUTE:
    case MISSING_ATTR_VALUE:
    case XML_ATTRIBUTE_VALUE:
    case PROPRIETARY_ATTRIBUTE:
    case JOINING_ATTRIBUTE:
        messageNode(doc, TidyWarning, code, node, fmt, tagdesc, name);
        break;

    case MISMATCHED_ATTRIBUTE_WARN:
        version = doc->lexer->versionEmitted == 0 ? doc->lexer->doctype : doc->lexer->versionEmitted;
        extra_string = TY_(HTMLVersionNameFromCode)(version, 0);
        if (!extra_string)
            extra_string = tidyLocalizedString(STRING_HTML_PROPRIETARY);
        messageNode(doc, TidyWarning, code, node, fmt, tagdesc, name, extra_string);
        break;

    case MISMATCHED_ATTRIBUTE_ERROR:
        version = doc->lexer->versionEmitted == 0 ? doc->lexer->doctype : doc->lexer->versionEmitted;
        extra_string = TY_(HTMLVersionNameFromCode)(version, 0);
        if (!extra_string)
            extra_string = tidyLocalizedString(STRING_HTML_PROPRIETARY);
        messageNode(doc, TidyError, code, node, fmt, tagdesc, name, extra_string);
        break;

    case BAD_ATTRIBUTE_VALUE:
    case BAD_ATTRIBUTE_VALUE_REPLACED:
    case INVALID_ATTRIBUTE:
    case INSERTING_AUTO_ATTRIBUTE:
        messageNode(doc, TidyWarning, code, node, fmt, tagdesc, name, value);
        break;

    case UNEXPECTED_QUOTEMARK:
    case MISSING_QUOTEMARK:
    case ID_NAME_MISMATCH:
    case BACKSLASH_IN_URI:
    case FIXED_BACKSLASH:
    case ILLEGAL_URI_REFERENCE:
    case ESCAPED_ILLEGAL_URI:
    case NEWLINE_IN_URI:
    case WHITE_IN_URI:
    case UNEXPECTED_GT:
    case INVALID_XML_ID:
    case UNEXPECTED_EQUALSIGN:
        messageNode(doc, TidyWarning, code, node, fmt, tagdesc);
        break;

    case XML_ID_SYNTAX:
    case PROPRIETARY_ATTR_VALUE:
    case ANCHOR_NOT_UNIQUE:
    case ATTR_VALUE_NOT_LCASE:
        messageNode(doc, TidyWarning, code, node, fmt, tagdesc, value);
        break;


    case MISSING_IMAGEMAP:
        messageNode(doc, TidyWarning, code, node, fmt, tagdesc);
        doc->badAccess |= BA_MISSING_IMAGE_MAP;
        break;

    case REPEATED_ATTRIBUTE:
        messageNode(doc, TidyWarning, code, node, fmt, 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;
        messageLexer(doc, TidyWarning, code, fmt, tagdesc);
        break;
    }
}
示例#7
0
/* lexer is not defined when this is called */
void TY_(ReportBadArgument)( TidyDocImpl* doc, ctmbstr option )
{
    assert( option != NULL );
    message( doc, TidyConfig, STRING_MISSING_MALFORMED, tidyLocalizedString(STRING_MISSING_MALFORMED), option );
}
示例#8
0
/* lexer is not defined when this is called */
void TY_(ReportUnknownOption)( TidyDocImpl* doc, ctmbstr option )
{
    assert( option != NULL );
    message( doc, TidyConfig, STRING_UNKNOWN_OPTION, tidyLocalizedString(STRING_UNKNOWN_OPTION), option );
}
示例#9
0
void TY_(AccessibilityHelloMessage)( TidyDocImpl* doc )
{
    tidy_out(doc, "\n%s\n\n", tidyLocalizedString(STRING_HELLO_ACCESS));
}
示例#10
0
void TY_(GeneralInfo)( TidyDocImpl* doc )
{
    if (!cfgBool(doc, TidyShowInfo)) return;
    tidy_out(doc, "%s", tidyLocalizedString(TEXT_GENERAL_INFO));
    tidy_out(doc, "%s", tidyLocalizedString(TEXT_GENERAL_INFO_PLEA));
}
示例#11
0
void TY_(NeedsAuthorIntervention)( TidyDocImpl* doc )
{
    tidy_out(doc, "%s", tidyLocalizedString(TEXT_NEEDS_INTERVENTION));
}
示例#12
0
void TY_(UnknownFile)( TidyDocImpl* doc, ctmbstr program, ctmbstr file )
{
    message( doc, TidyConfig, tidyLocalizedString(STRING_UNKNOWN_FILE), program, file );
}
示例#13
0
void TY_(UnknownOption)( TidyDocImpl* doc, char c )
{
    message( doc, TidyConfig, tidyLocalizedString(STRING_UNRECZD_OPTION), c );
}
示例#14
0
void TY_(ReportError)(TidyDocImpl* doc, Node *element, Node *node, uint code)
{
    char nodedesc[ 256 ] = {0};
    char elemdesc[ 256 ] = {0};
    Node* rpt = ( element ? element : node );
    ctmbstr fmt = tidyLocalizedString(code);
    uint versionEmitted, declared, version;
    ctmbstr extra_string = NULL;

    assert( fmt != NULL );

    TagToString(node, nodedesc, sizeof(nodedesc));

    switch ( code )
    {
    case MISSING_STARTTAG:
    case UNEXPECTED_ENDTAG:
    case TOO_MANY_ELEMENTS:
    case INSERTING_TAG:
        messageNode(doc, TidyWarning, code, node, fmt, node->element);
        break;

    case USING_BR_INPLACE_OF:
    case CANT_BE_NESTED:
    case PROPRIETARY_ELEMENT:
    case UNESCAPED_ELEMENT:
    case NOFRAMES_CONTENT:
        messageNode(doc, TidyWarning, code, node, fmt, nodedesc);
        break;

    case ELEMENT_VERS_MISMATCH_WARN:
        versionEmitted = doc->lexer->versionEmitted;
        declared = doc->lexer->doctype;
        version = versionEmitted == 0 ? declared : versionEmitted;
        extra_string = TY_(HTMLVersionNameFromCode)(version, 0);
        if (!extra_string)
            extra_string = tidyLocalizedString(STRING_HTML_PROPRIETARY);
        messageNode(doc, TidyWarning, code, node, fmt, nodedesc, extra_string);
        break;

    case ELEMENT_VERS_MISMATCH_ERROR:
        versionEmitted = doc->lexer->versionEmitted;
        declared = doc->lexer->doctype;
        version = versionEmitted == 0 ? declared : versionEmitted;
        extra_string = TY_(HTMLVersionNameFromCode)(version, 0);
        if (!extra_string)
            extra_string = tidyLocalizedString(STRING_HTML_PROPRIETARY);
        messageNode(doc, TidyError, code, node, fmt, nodedesc, extra_string);
        break;

    case MISSING_TITLE_ELEMENT:
    case INCONSISTENT_VERSION:
    case MALFORMED_DOCTYPE:
    case CONTENT_AFTER_BODY:
    case MALFORMED_COMMENT:
    case BAD_COMMENT_CHARS:
    case BAD_XML_COMMENT:
    case BAD_CDATA_CONTENT:
    case INCONSISTENT_NAMESPACE:
    case DOCTYPE_AFTER_TAGS:
    case DTYPE_NOT_UPPER_CASE:
        messageNode(doc, TidyWarning, code, rpt, "%s", fmt);
        break;

    case COERCE_TO_ENDTAG:
    case NON_MATCHING_ENDTAG:
        messageNode(doc, TidyWarning, code, rpt, fmt, node->element, node->element);
        break;

    case UNEXPECTED_ENDTAG_IN:
    case TOO_MANY_ELEMENTS_IN:
        messageNode(doc, TidyWarning, code, node, fmt, node->element, element->element);
        if (cfgBool( doc, TidyShowWarnings ))
            messageNode(doc, TidyInfo, PREVIOUS_LOCATION, node, tidyLocalizedString(PREVIOUS_LOCATION),
                        element->element);
        break;

    case ENCODING_IO_CONFLICT:
    case MISSING_DOCTYPE:
    case SPACE_PRECEDING_XMLDECL:
        messageNode(doc, TidyWarning, code, node, "%s", fmt);
        break;

    case TRIM_EMPTY_ELEMENT:
    case ILLEGAL_NESTING:
    case UNEXPECTED_END_OF_FILE:
    case ELEMENT_NOT_EMPTY:
        TagToString(element, elemdesc, sizeof(elemdesc));
        messageNode(doc, TidyWarning, code, element, fmt, elemdesc);
        break;


    case MISSING_ENDTAG_FOR:
        messageNode(doc, TidyWarning, code, rpt, fmt, element->element);
        break;

    case MISSING_ENDTAG_BEFORE:
        messageNode(doc, TidyWarning, code, rpt, fmt, element->element, nodedesc);
        break;

    case DISCARDING_UNEXPECTED:
        /* Force error if in a bad form, or 
           Issue #166 - repeated <main> element
        */
        messageNode(doc, doc->badForm ? TidyError : TidyWarning, code, node, fmt, nodedesc);
        break;

    case TAG_NOT_ALLOWED_IN:
        messageNode(doc, TidyWarning, code, node, fmt, nodedesc, element->element);
        if (cfgBool( doc, TidyShowWarnings ))
            messageNode(doc, TidyInfo, PREVIOUS_LOCATION, element,
                        tidyLocalizedString(PREVIOUS_LOCATION), element->element);
        break;

    case REPLACING_UNEX_ELEMENT:
        TagToString(element, elemdesc, sizeof(elemdesc));
        messageNode(doc, TidyWarning, code, rpt, fmt, elemdesc, nodedesc);
        break;
    case REMOVED_HTML5:
        messageNode(doc, TidyError, code, rpt, fmt, nodedesc);
        break;
    }
}
示例#15
0
void TY_(FileError)( TidyDocImpl* doc, ctmbstr file, TidyReportLevel level )
{
    message( doc, level, FILE_CANT_OPEN, tidyLocalizedString(FILE_CANT_OPEN), file );
}
示例#16
0
void TY_(ErrorSummary)( TidyDocImpl* doc )
{
    ctmbstr encnam = tidyLocalizedString(STRING_SPECIFIED);
    int charenc = cfg( doc, TidyCharEncoding ); 
    if ( charenc == WIN1252 ) 
        encnam = "Windows-1252";
    else if ( charenc == MACROMAN )
        encnam = "MacRoman";
    else if ( charenc == IBM858 )
        encnam = "ibm858";
    else if ( charenc == LATIN0 )
        encnam = "latin0";

    /* adjust badAccess to that it is 0 if frames are ok */
    if ( doc->badAccess & (BA_USING_FRAMES | BA_USING_NOFRAMES) )
    {
        if (!((doc->badAccess & BA_USING_FRAMES) && !(doc->badAccess & BA_USING_NOFRAMES)))
            doc->badAccess &= ~(BA_USING_FRAMES | BA_USING_NOFRAMES);
    }

    if (doc->badChars)
    {
#if 0
        if ( doc->badChars & WINDOWS_CHARS )
        {
            tidy_out(doc, "%s", tidyLocalizedString(TEXT_WINDOWS_CHARS));
        }
#endif
        if (doc->badChars & BC_VENDOR_SPECIFIC_CHARS)
        {
            tidy_out(doc, tidyLocalizedString(TEXT_VENDOR_CHARS), encnam);
        }
        if ((doc->badChars & BC_INVALID_SGML_CHARS) || (doc->badChars & BC_INVALID_NCR))
        {
            tidy_out(doc, tidyLocalizedString(TEXT_SGML_CHARS), encnam);
        }
        if (doc->badChars & BC_INVALID_UTF8)
        {
            tidy_out(doc, "%s", tidyLocalizedString(TEXT_INVALID_UTF8));
        }

#if SUPPORT_UTF16_ENCODINGS

      if (doc->badChars & BC_INVALID_UTF16)
      {
          tidy_out(doc, "%s", tidyLocalizedString(TEXT_INVALID_UTF16));
      }

#endif

      if (doc->badChars & BC_INVALID_URI)
      {
          tidy_out(doc, "%s", tidyLocalizedString(TEXT_INVALID_URI));
      }
    }

    if (doc->badForm & flg_BadForm) /* Issue #166 - changed to BIT flag to support other errors */
    {
        tidy_out(doc, "%s", tidyLocalizedString(TEXT_BAD_FORM));
    }

    if (doc->badForm & flg_BadMain) /* Issue #166 - repeated <main> element */
    {
        tidy_out(doc, "%s", tidyLocalizedString(TEXT_BAD_MAIN));
    }
    
    if (doc->badAccess)
    {
        /* Tidy "classic" accessibility tests */
        if ( cfg(doc, TidyAccessibilityCheckLevel) == 0 )
        {
            if (doc->badAccess & BA_MISSING_SUMMARY)
            {
                tidy_out(doc, "%s", tidyLocalizedString(TEXT_M_SUMMARY));
            }

            if (doc->badAccess & BA_MISSING_IMAGE_ALT)
            {
                tidy_out(doc, "%s", tidyLocalizedString(TEXT_M_IMAGE_ALT));
            }

            if (doc->badAccess & BA_MISSING_IMAGE_MAP)
            {
                tidy_out(doc, "%s", tidyLocalizedString(TEXT_M_IMAGE_MAP));
            }

            if (doc->badAccess & BA_MISSING_LINK_ALT)
            {
                tidy_out(doc, "%s", tidyLocalizedString(TEXT_M_LINK_ALT));
            }

            if ((doc->badAccess & BA_USING_FRAMES) && !(doc->badAccess & BA_USING_NOFRAMES))
            {
                tidy_out(doc, "%s", tidyLocalizedString(TEXT_USING_FRAMES));
            }
        }

        tidy_out(doc, "%s", tidyLocalizedString(TEXT_ACCESS_ADVICE1));
        if ( cfg(doc, TidyAccessibilityCheckLevel) > 0 )
            tidy_out(doc, "%s", tidyLocalizedString(TEXT_ACCESS_ADVICE2));
        tidy_out(doc, ".\n" );
    }

    if (doc->badLayout)
    {
        if (doc->badLayout & USING_LAYER)
        {
            tidy_out(doc, "%s", tidyLocalizedString(TEXT_USING_LAYER));
        }

        if (doc->badLayout & USING_SPACER)
        {
            tidy_out(doc, "%s", tidyLocalizedString(TEXT_USING_SPACER));
        }

        if (doc->badLayout & USING_FONT)
        {
            tidy_out(doc, "%s", tidyLocalizedString(TEXT_USING_FONT));
        }

        if (doc->badLayout & USING_NOBR)
        {
            tidy_out(doc, "%s", tidyLocalizedString(TEXT_USING_NOBR));
        }

        if (doc->badLayout & USING_BODY)
        {
            tidy_out(doc, "%s", tidyLocalizedString(TEXT_USING_BODY));
        }
    }
}
示例#17
0
void TY_(ReportSurrogateError)(TidyDocImpl* doc, uint code, uint c1, uint c2)
{
    ctmbstr fmt = tidyLocalizedString(code);
    if (fmt)
        messageLexer(doc, TidyWarning, code, fmt, c1, c2);
}