From 62aab82ead701780bd397dd99f792ce7e993cb02 Mon Sep 17 00:00:00 2001 From: Ivanov Anton Date: Fri, 8 Oct 2010 13:39:36 +0200 Subject: [PATCH] Fixed crash while processing page with invalid `style' attribute. --- src/ChangeLog | 4 ++++ src/html-url.c | 19 +++++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index c7eba319..8d15a17d 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2010-10-08 Ivanov Anton (tiny change) + + * src/html-url.c (check_style_attr): Skip quotes when they are present. + 2010-10-06 Giuseppe Scrivano * main.c (main): Remove unused variable `status'. diff --git a/src/html-url.c b/src/html-url.c index 523f5e0d..54a0141c 100644 --- a/src/html-url.c +++ b/src/html-url.c @@ -364,12 +364,27 @@ static void check_style_attr (struct taginfo *tag, struct map_context *ctx) { int attrind; + int raw_start; + int raw_len; char *style = find_attr (tag, "style", &attrind); if (!style) return; - /* raw pos and raw size include the quotes, hence the +1 -2 */ - get_urls_css (ctx, ATTR_POS(tag,attrind,ctx)+1, ATTR_SIZE(tag,attrind)-2); + /* raw pos and raw size include the quotes, skip them when they are + present. */ + raw_start = ATTR_POS (tag, attrind, ctx); + raw_len = ATTR_SIZE (tag, attrind); + if( *(char *)(ctx->text + raw_start) == '\'' + || *(char *)(ctx->text + raw_start) == '"') + { + raw_start += 1; + raw_len -= 2; + } + + if(raw_len <= 0) + return; + + get_urls_css (ctx, raw_start, raw_len); } /* All the tag_* functions are called from collect_tags_mapper, as -- 2.39.2