From 2852ad4c63bf5ab687775f0ed93e133b463c3da6 Mon Sep 17 00:00:00 2001 From: Jim Derry Date: Fri, 29 Sep 2017 15:42:03 -0400 Subject: [PATCH] Fix #588 and #591 - Apply @geoffmcl's patches and tested. --- src/attrs.c | 11 ++++++----- src/clean.c | 4 +++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/attrs.c b/src/attrs.c index adb2695..227f40a 100644 --- a/src/attrs.c +++ b/src/attrs.c @@ -1517,15 +1517,16 @@ static void CheckLowerCaseAttrValue( TidyDocImpl* doc, Node *node, AttVal *attva } } -/* methods for checking value of a specific attribute */ -#ifdef _WIN32 +/* Issue #588 - use simple macros only! + Seems 'isalnum(c)' is undefined and can + cause an assert or a SIGSEGV in some libraries + if 'c' is not EOF, or in the range 0 to 0xff, + so avoid using it. +*/ #define ISUPPER(a) ((a >= 'A') && (a <= 'Z')) #define ISLOWER(a) ((a >= 'a') && (a <= 'z')) #define ISNUMERIC(a) ((a >= '0') && (a <= '9')) #define ISALNUM(a) (ISUPPER(a) || ISLOWER(a) || ISNUMERIC(a)) -#else -#define ISALNUM(a) isalnum(a) -#endif static Bool IsURLCodePoint( ctmbstr p, uint *increment ) { diff --git a/src/clean.c b/src/clean.c index f3881b3..f59767b 100644 --- a/src/clean.c +++ b/src/clean.c @@ -1902,7 +1902,9 @@ void TY_(CleanWord2000)( TidyDocImpl* doc, Node *node) attval = node->attributes; while ( attval ) { next_attr = attval->next; - if ( strcmp(attval->attribute, "xmlns") != 0 ) + + /* Issue #591 - take care of a NULL attribute, too. */ + if ( !attval->attribute || ( strcmp(attval->attribute, "xmlns") != 0 )) TY_(ReportAttrError)(doc, node, attval, PROPRIETARY_ATTRIBUTE); attval = next_attr; }