diff options
-rw-r--r-- | ChangeLog | 1 | ||||
-rw-r--r-- | dlib/dlib.c | 20 | ||||
-rw-r--r-- | dlib/dlib.h | 1 | ||||
-rw-r--r-- | src/html.cc | 2 |
4 files changed, 23 insertions, 1 deletions
@@ -87,6 +87,7 @@ dillo-fltk2 - Fixed a bug in Html_parse_entity. - Fixed a bug in a_Url_cmp. - Fixed a bug in Cookies_parse_one. Set it to a single return potint too! + - Added dStr_memmem() to dlib. Patches: place +- Fixed a problem with locally-installed dpis. - Added code for optional image loading (nice interface) very advanced! diff --git a/dlib/dlib.c b/dlib/dlib.c index 78fa951d..862e642f 100644 --- a/dlib/dlib.c +++ b/dlib/dlib.c @@ -415,6 +415,26 @@ int dStr_cmp(Dstr *ds1, Dstr *ds2) } /* + * Return a pointer to the first occurrence of needle in haystack. + */ +char *dStr_memmem(Dstr *haystack, Dstr *needle) +{ + int i; + + if (needle && haystack) { + if (needle->len == 0) + return haystack->str; + + for (i = 0; i <= (haystack->len - needle->len); i++) { + if (haystack->str[i] == needle->str[0] && + !memcmp(haystack->str + i, needle->str, needle->len)) + return haystack->str + i; + } + } + return NULL; +} + +/* *- dList --------------------------------------------------------------------- */ diff --git a/dlib/dlib.h b/dlib/dlib.h index d86adc96..7bcac739 100644 --- a/dlib/dlib.h +++ b/dlib/dlib.h @@ -107,6 +107,7 @@ void dStr_vsprintf (Dstr *ds, const char *format, va_list argp); void dStr_sprintf (Dstr *ds, const char *format, ...); void dStr_sprintfa (Dstr *ds, const char *format, ...); int dStr_cmp(Dstr *ds1, Dstr *ds2); +char *dStr_memmem(Dstr *haystack, Dstr *needle); /* *-- dList -------------------------------------------------------------------- diff --git a/src/html.cc b/src/html.cc index 7b604c1a..15a7f726 100644 --- a/src/html.cc +++ b/src/html.cc @@ -4097,7 +4097,7 @@ static void Html_submit_form2(DilloHtml *html, DilloHtmlForm *form, dStr_sprintf(boundary, "---------------------------%d%d%d", rand(), rand(), rand()); dStr_truncate(boundary, 70); - success = !strstr(DataStr->str, boundary->str); + success = (dStr_memmem(DataStr, boundary) == NULL); } dList_free(values); dStr_truncate(DataStr, 0); |