mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-24 04:56:50 +03:00
Use case-insensitive strstr to match "stylesheet"
svn path=/trunk/netsurf/; revision=2689
This commit is contained in:
parent
467d9679f8
commit
2cb285209e
@ -593,10 +593,10 @@ bool html_find_stylesheets(struct content *c, xmlNode *head)
|
||||
/* rel=<space separated list, including 'stylesheet'> */
|
||||
if ((rel = (char *) xmlGetProp(node, (const xmlChar *) "rel")) == NULL)
|
||||
continue;
|
||||
if (strstr(rel, "stylesheet") == 0) {
|
||||
if (strcasestr(rel, "stylesheet") == 0) {
|
||||
xmlFree(rel);
|
||||
continue;
|
||||
} else if (strstr(rel, "alternate")) {
|
||||
} else if (strcasestr(rel, "alternate")) {
|
||||
/* Ignore alternate stylesheets */
|
||||
xmlFree(rel);
|
||||
continue;
|
||||
|
@ -214,3 +214,24 @@ const char *rfc1123_date(time_t t)
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Case insensitive strstr implementation
|
||||
*
|
||||
* \param haystack String to search in
|
||||
* \param needle String to look for
|
||||
* \return Pointer to start of found substring, or NULL if not found
|
||||
*/
|
||||
char *strcasestr(const char *haystack, const char *needle)
|
||||
{
|
||||
size_t needle_len = strlen(needle);
|
||||
const char * last_start = haystack + (strlen(haystack) - needle_len);
|
||||
|
||||
while (haystack <= last_start) {
|
||||
if (strncasecmp(haystack, needle, needle_len) == 0)
|
||||
return (char *)haystack;
|
||||
haystack++;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
@ -56,6 +56,7 @@ void regcomp_wrapper(regex_t *preg, const char *regex, int cflags);
|
||||
void unicode_transliterate(unsigned int c, char **r);
|
||||
char *human_friendly_bytesize(unsigned long bytesize);
|
||||
const char *rfc1123_date(time_t t);
|
||||
char *strcasestr(const char *haystack, const char *needle);
|
||||
|
||||
/* Platform specific functions */
|
||||
void die(const char * const error);
|
||||
|
Loading…
Reference in New Issue
Block a user