mirror of
https://github.com/php/php-src.git
synced 2025-01-26 21:54:16 +08:00
get_meta_tags() was using php_stristr() so it needed to be changed.
Optimized it to use php_memnstr() directly.
This commit is contained in:
parent
17ff0f3af3
commit
33d82cb6d1
@ -386,6 +386,7 @@ PHP_FUNCTION(get_meta_tags)
|
||||
pval **filename, **arg2;
|
||||
FILE *fp;
|
||||
char buf[8192];
|
||||
char buf_lcase[8192];
|
||||
int use_include_path = 0;
|
||||
int issock=0, socketd=0;
|
||||
int len, var_namelen;
|
||||
@ -432,14 +433,19 @@ PHP_FUNCTION(get_meta_tags)
|
||||
}
|
||||
/* Now loop through the file and do the magic quotes thing if needed */
|
||||
memset(buf, 0, 8191);
|
||||
while((FP_FGETS(buf,8191,socketd,fp,issock) != NULL)
|
||||
&& !php_stristr(buf,"</head>")) {
|
||||
if(php_stristr(buf,"<meta")) {
|
||||
while((FP_FGETS(buf,8191,socketd,fp,issock) != NULL)) {
|
||||
memcpy(buf_lcase, buf, 8191);
|
||||
php_strtolower(buf_lcase, 8191);
|
||||
if (php_memnstr(buf_lcase, "</head>", sizeof("</head>")-1, buf_lcase + 8191))
|
||||
break;
|
||||
|
||||
if(php_memnstr(buf_lcase, "<meta", sizeof("<meta")-1, buf_lcase + 8191)) {
|
||||
|
||||
memset(var_name,0,50);
|
||||
/* get the variable name from the name attribute of the meta tag */
|
||||
tmp=php_stristr(buf,"name=\"");
|
||||
tmp = php_memnstr(buf_lcase, "name=\"", sizeof("name=\"")-1, buf_lcase + 8191);
|
||||
if(tmp) {
|
||||
tmp = &buf[tmp - buf_lcase];
|
||||
tmp+=6;
|
||||
end=strstr(tmp,"\"");
|
||||
if(end) {
|
||||
@ -473,8 +479,9 @@ PHP_FUNCTION(get_meta_tags)
|
||||
}
|
||||
|
||||
/* get the variable value from the content attribute of the meta tag */
|
||||
tmp=php_stristr(buf,"content=\"");
|
||||
tmp = php_memnstr(buf_lcase, "content=\"", sizeof("content=\"")-1, buf_lcase + 8191);
|
||||
if(tmp) {
|
||||
tmp = &buf[tmp - buf_lcase];
|
||||
tmp+=9;
|
||||
end=strstr(tmp,"\"");
|
||||
if(end) {
|
||||
|
@ -92,7 +92,7 @@ extern PHPAPI char *php_addcslashes(char *string, int length, int *new_length, i
|
||||
extern PHPAPI void php_stripslashes(char *string, int *len);
|
||||
extern PHPAPI void php_stripcslashes(char *string, int *len);
|
||||
extern PHPAPI void php_dirname(char *str, int len);
|
||||
extern PHPAPI char *php_stristr(unsigned char *s, unsigned char *t);
|
||||
extern PHPAPI char *php_stristr(unsigned char *s, unsigned char *t, size_t s_len, size_t t_len);
|
||||
extern PHPAPI char *php_str_to_str(char *haystack, int length, char *needle,
|
||||
int needle_len, char *str, int str_len, int *_new_length);
|
||||
extern PHPAPI void php_trim(pval *str, pval *return_value, int mode);
|
||||
@ -102,5 +102,6 @@ extern PHPAPI void php_char_to_str(char *str, uint len, char from, char *to, int
|
||||
|
||||
extern PHPAPI void php_implode(pval *delim, pval *arr, pval *return_value);
|
||||
extern PHPAPI void php_explode(pval *delim, pval *str, pval *return_value);
|
||||
PHPAPI inline char *php_memnstr(char *haystack, char *needle, int needle_len, char *end);
|
||||
|
||||
#endif /* _PHPSTRING_H */
|
||||
|
Loading…
Reference in New Issue
Block a user