1.Manipulate动作重构修改
2.修改pangu_send_log中log字段名 3.修改可信证书颁发机构表名
This commit is contained in:
@@ -279,72 +279,71 @@ size_t execute_replace_rule(const char * in, size_t in_sz,
|
||||
}
|
||||
}
|
||||
|
||||
size_t insert_string(char * in, size_t in_sz, const char *insert_on, const char *stype, const char *type, char** out)
|
||||
size_t insert_string(char * in, size_t in_sz, const char *insert_on, const char *script, const char *type, char** out)
|
||||
{
|
||||
char *target=NULL;
|
||||
size_t outlen=0, target_size=0;
|
||||
char position[]="</head>";
|
||||
size_t target_size=0;
|
||||
|
||||
/* "<script type=\"text/javascript\" class=\"RQ_SCRIPT\"></script>"*/
|
||||
int js_type_len = 58;
|
||||
/*"<style type=\"text/css\" class=\"RQ_SCRIPT\"></style>"*/
|
||||
int css_type_len = 49;
|
||||
|
||||
char* head_string=NULL;
|
||||
|
||||
if (0==strcasecmp(type, "css"))
|
||||
{
|
||||
target_size = in_sz+strlen(stype)+1+css_type_len;
|
||||
target = ALLOC(char, target_size + 1);
|
||||
}
|
||||
|
||||
if (0==strcasecmp(type, "js"))
|
||||
{
|
||||
target_size = in_sz+strlen(stype)+1+js_type_len;
|
||||
target = ALLOC(char, target_size + 1);
|
||||
}
|
||||
const char* js_style="<script type=\"text/javascript\" class=\"RQ_SCRIPT\">%s</script>";
|
||||
const char* css_style= "<style type=\"text/css\" class=\"RQ_SCRIPT\">%s</style>";
|
||||
const char* this_style=NULL;
|
||||
size_t concat_len=0, concat_size=0;
|
||||
char* concat_style=NULL;
|
||||
char* insert_from=NULL;
|
||||
size_t offset=0;
|
||||
|
||||
if (insert_on != NULL && 0==strcasecmp(insert_on, "after-page-load"))
|
||||
{
|
||||
memcpy(position, "</body>", sizeof(position));
|
||||
insert_from=strstr(in, "</body>");
|
||||
}
|
||||
head_string=strstr(in, position);
|
||||
if (head_string != NULL)
|
||||
else
|
||||
{
|
||||
strncat(target, in, MIN((unsigned int)(head_string-in), target_size));
|
||||
size_t style_len = 0; char *style_msg = NULL;
|
||||
if (0==strcasecmp(type, "js"))
|
||||
{
|
||||
style_len = strlen(stype)+1+js_type_len;
|
||||
style_msg = ALLOC(char, style_len);
|
||||
snprintf(style_msg, style_len, "<script type=\"text/javascript\" class=\"RQ_SCRIPT\">%s</script>", stype);
|
||||
}
|
||||
if (0==strcasecmp(type, "css"))
|
||||
{
|
||||
style_len = strlen(stype)+1+css_type_len;
|
||||
style_msg = ALLOC(char, style_len);
|
||||
snprintf(style_msg, style_len, "<style type=\"text/css\" class=\"RQ_SCRIPT\">%s</style>", stype);
|
||||
}
|
||||
insert_from=strstr(in, "</head>");
|
||||
}
|
||||
if(!insert_from)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
strncat(target, style_msg, MIN(style_len, target_size));
|
||||
free(style_msg);
|
||||
style_msg = NULL;
|
||||
strncat(target, head_string, (target_size - (head_string-in) - style_len));
|
||||
target[target_size-1] = '\0';
|
||||
outlen = target_size;
|
||||
*out = target;
|
||||
}else
|
||||
if (0==strcasecmp(type, "css"))
|
||||
{
|
||||
free(target);
|
||||
target = NULL;
|
||||
outlen = 0;
|
||||
this_style=css_style;
|
||||
}
|
||||
return outlen;
|
||||
else if (0==strcasecmp(type, "js"))
|
||||
{
|
||||
this_style=js_style;
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(0);
|
||||
}
|
||||
concat_size = strlen(script)+1+strlen(this_style);
|
||||
concat_style = ALLOC(char, concat_size);
|
||||
concat_len=snprintf(concat_style, concat_size,
|
||||
this_style,
|
||||
script);
|
||||
|
||||
target_size = in_sz+concat_len;
|
||||
target = ALLOC(char, target_size);
|
||||
assert((unsigned int)(insert_from-in) <= target_size);
|
||||
offset=0;
|
||||
memcpy(target+offset, in, insert_from-in);
|
||||
offset+=insert_from-in;
|
||||
memcpy(target+offset, concat_style, concat_len);
|
||||
offset+=concat_len;
|
||||
memcpy(target+offset, insert_from, in_sz-(insert_from-in));
|
||||
offset+=in_sz-(insert_from-in);
|
||||
assert(target_size==offset+1);
|
||||
|
||||
free(concat_style);
|
||||
concat_style = NULL;
|
||||
*out=target;
|
||||
return target_size;
|
||||
}
|
||||
|
||||
size_t execute_insert_rule(char * in, size_t in_sz, const struct insert_rule * rules, char** out)
|
||||
{
|
||||
return insert_string(in, in_sz, rules->position, rules->stype, rules->type, out);
|
||||
return insert_string(in, in_sz, rules->position, rules->script, rules->type, out);
|
||||
}
|
||||
|
||||
void simple_replace(const char* find, const char* replacement, const char* input, size_t in_sz, char** output, size_t *output_sz)
|
||||
|
||||
Reference in New Issue
Block a user