From 23d36dbdc71f7eb62bfa02ee64a57c1e1200ec20 Mon Sep 17 00:00:00 2001 From: Amos Jeffries Date: Mon, 2 Mar 2009 23:10:46 +1300 Subject: [PATCH] Author: Francesco Chemolli Fixed String search --- src/HttpHeaderTools.cc | 4 ++-- src/String.cc | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/HttpHeaderTools.cc b/src/HttpHeaderTools.cc index 33ac3d5712..85c827ddee 100644 --- a/src/HttpHeaderTools.cc +++ b/src/HttpHeaderTools.cc @@ -189,7 +189,7 @@ int strListIsSubstr(const String * list, const char *s, char del) { assert(list && del); - return list->pos(s) != 0; + return (list->find(s) != String::npos); /** \note * Note: the original code with a loop is broken because it uses strstr() @@ -359,7 +359,7 @@ httpHeaderParseQuotedString (const char *start, String *val) /** * Checks the anonymizer (header_access) configuration. - * + * * \retval 0 Header is explicitly blocked for removal * \retval 1 Header is explicitly allowed * \retval 1 Header has been replaced, the current version can be used. diff --git a/src/String.cc b/src/String.cc index 90758326fe..a68af96883 100644 --- a/src/String.cc +++ b/src/String.cc @@ -437,18 +437,24 @@ checkNullString(const char *p) const char * String::pos(char const *aString) const { + if (undefined()) + return NULL; return strstr(termedBuf(), aString); } const char * String::pos(char const ch) const { + if (undefined()) + return NULL; return strchr(termedBuf(), ch); } const char * String::rpos(char const ch) const { + if (undefined()) + return NULL; return strrchr(termedBuf(), (ch)); } -- 2.47.3