W3C home > Mailing lists > Public > html-tidy@w3.org > April to June 2000

Bug and suggested fix: Tidy lets attribute names begin with '-', '.', or a digit

From: Randy Waki <rwaki@flipdog.com>
Date: Fri, 14 Apr 2000 15:34:22 -0600
To: <html-tidy@w3.org>, <dsr@w3.org>
Message-ID: <000301bfa659$328f3750$28eee13f@whizbang.com>
13-Jan-2000 Tidy doesn't complain about illegal attribute names
beginning with '-', '.', or a digit.  The problem is in
IsValidAttrName() in lexer.c where the first character isn't being
distinguished.  The following fix works for us.

In html.h, add a new lexer char type:

#define firstnamechar 128


In lexer.c, InitMap(), make ':', '_', and letters firstnamechars by
changing:

    MapStr("-.:_", namechar);
 to
    MapStr("-.", namechar);
    MapStr(":_", namechar|firstnamechar);

 and

    MapStr("abcdefghijklmnopqrstuvwxyz", lowercase|letter|namechar);
    MapStr("ABCDEFGHIJKLMNOPQRSTUVWXYZ", uppercase|letter|namechar);
 to
    MapStr("abcdefghijklmnopqrstuvwxyz",
lowercase|letter|namechar|firstnamechar);
    MapStr("ABCDEFGHIJKLMNOPQRSTUVWXYZ",
uppercase|letter|namechar|firstnamechar);


In lexer.c, IsValidAttrName(), check for an illegal first character:

    int i = 0;      // Existing line, unchanged

    if (wstrlen(attr) > 0)
    {
        c = attr[0];
        map = MAP(c);
        if ((map & firstnamechar) == 0)
            return false;
    }

    for( i = 0; i < wstrlen(attr); i++)  // Existing line, unchanged


Thanks,
Randy
Received on Friday, 14 April 2000 17:36:19 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 3 April 2012 06:13:43 GMT