Issue #345 - discard leading spaces in href
This commit is contained in:
parent
e8ca2aa5f3
commit
7d0d8a853a
16
src/attrs.c
16
src/attrs.c
|
@ -1500,16 +1500,32 @@ void TY_(CheckUrl)( TidyDocImpl* doc, Node *node, AttVal *attval)
|
|||
|
||||
if ( cfgBool(doc, TidyFixUri) && escape_count )
|
||||
{
|
||||
Bool hadnonspace = no;
|
||||
len = TY_(tmbstrlen)(p) + escape_count * 2 + 1;
|
||||
dest = (tmbstr) TidyDocAlloc(doc, len);
|
||||
|
||||
for (i = 0; 0 != (c = p[i]); ++i)
|
||||
{
|
||||
if ((c > 0x7e) || (c <= 0x20) || (strchr("<>", c)))
|
||||
{
|
||||
if (c == 0x20)
|
||||
{
|
||||
/* #345 - special case for leading spaces - discard */
|
||||
if (hadnonspace)
|
||||
pos += sprintf( dest + pos, "%%%02X", (byte)c );
|
||||
}
|
||||
else
|
||||
{
|
||||
pos += sprintf( dest + pos, "%%%02X", (byte)c );
|
||||
hadnonspace = yes;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
hadnonspace = yes;
|
||||
dest[pos++] = c;
|
||||
}
|
||||
}
|
||||
dest[pos] = 0;
|
||||
|
||||
TidyDocFree(doc, attval->value);
|
||||
|
|
Loading…
Reference in a new issue