From 85c9c54d0078b24e510e24313c4626260235d4ec Mon Sep 17 00:00:00 2001 From: Petr Baudis Date: Sun, 16 Jul 2006 22:22:16 +0200 Subject: [PATCH] Accept float widths (ceiling them) Especially percentages might be floats instead of integer, see e.g. http://www.armitunes.com/cgi-bin/icecast/playing.cgi. --- src/document/html/parser/parse.c | 3 ++- src/document/html/parser/table.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/document/html/parser/parse.c b/src/document/html/parser/parse.c index 9b4a5f96..fa1ed2d0 100644 --- a/src/document/html/parser/parse.c +++ b/src/document/html/parser/parse.c @@ -310,7 +310,8 @@ get_width(unsigned char *a, unsigned char *name, int limited, /* @end points into the @value string so check @end position * before freeing @value. */ - if (errno || *end || width >= INT_MAX) { + /* We will accept floats but ceil() them. */ + if (errno || (*end && *end != '.') || width >= INT_MAX) { /* Not a valid number. */ mem_free(value); return -1; diff --git a/src/document/html/parser/table.c b/src/document/html/parser/table.c index 00e1a460..02b379d8 100644 --- a/src/document/html/parser/table.c +++ b/src/document/html/parser/table.c @@ -128,7 +128,7 @@ get_column_width(unsigned char *attr, int *width, int sh, al[len - 1] = '\0'; errno = 0; n = strtoul(al, (char **) &en, 10); - if (!errno && n >= 0 && !*en) + if (!errno && n >= 0 && (!*en || *en == '.')) *width = WIDTH_RELATIVE - n; } else { int w = get_width(attr, "width", sh, html_context);