1.修改原数据流动作定义,增加操作定义
2.重构原操作重定向、替换 3.新增接口http_block、http_hijack、http_insert 4.注册处理策略表接口policy_table_new_cb等 5.注册处理用户自定域json处理接口policy_param_new等 6.添加对添加对注入脚本的测试用例
This commit is contained in:
@@ -113,6 +113,70 @@ TEST(PatternReplace, UTF8)
|
||||
return;
|
||||
}
|
||||
|
||||
TEST(PatternInsert, CSS)
|
||||
{
|
||||
const char* filename="./test_data/index_of__centos.html";
|
||||
const char* custom = "h1,h2{color: red;}ul.tabmain a{color: green;}";
|
||||
char *input=NULL, *output=NULL;
|
||||
size_t output_sz=0, input_sz = 0;
|
||||
|
||||
input = rt_read_file(filename, &input_sz);
|
||||
EXPECT_TRUE(input_sz>0);
|
||||
|
||||
output_sz = insert_string(input, input_sz, NULL, custom, "css", &output);
|
||||
|
||||
//printf("output = %s\n", output);
|
||||
|
||||
EXPECT_TRUE(output_sz>0);
|
||||
EXPECT_TRUE(NULL!=strstr(output, custom));
|
||||
free(output);
|
||||
free(input);
|
||||
}
|
||||
|
||||
TEST(PatternInsert, after_body)
|
||||
{
|
||||
const char* filename="./test_data/index_of__centos.html";
|
||||
const char* custom = "var now=new Date();var year=now.getYear()+1900;var month=now.getMonth()+1;var date=now.getDate();var day=now.getDay();\
|
||||
var time=\"curtime\"+year+\"year\"+month+\"month\"+date+\"date\"+week;alert(time);";
|
||||
char *input=NULL, *output=NULL;
|
||||
size_t output_sz=0, input_sz = 0;
|
||||
|
||||
input = rt_read_file(filename, &input_sz);
|
||||
EXPECT_TRUE(input_sz>0);
|
||||
|
||||
output_sz = insert_string(input, input_sz, "after-page-load", custom, "js", &output);
|
||||
|
||||
//printf("%s\n", output);
|
||||
|
||||
EXPECT_TRUE(output_sz>0);
|
||||
EXPECT_TRUE(NULL!=strstr(output, custom));
|
||||
|
||||
free(input);
|
||||
free(output);
|
||||
output = NULL;
|
||||
}
|
||||
|
||||
TEST(PatternInsert, before_body)
|
||||
{
|
||||
const char* filename="./test_data/index_of__centos.html";
|
||||
const char* custom = "var now=new Date();var year=now.getYear()+1900;var month=now.getMonth()+1;var date=now.getDate();var day=now.getDay();\
|
||||
var time=\"curtime\"+year+\"year\"+month+\"month\"+date+\"date\"+week;alert(time);";
|
||||
char *input=NULL, *output=NULL;
|
||||
size_t output_sz=0, input_sz = 0;
|
||||
|
||||
input = rt_read_file(filename, &input_sz);
|
||||
EXPECT_TRUE(input_sz>0);
|
||||
|
||||
output_sz = insert_string(input, input_sz, "before-page-load", custom, "js", &output);
|
||||
//printf("%s\n", output);
|
||||
|
||||
EXPECT_TRUE(output_sz>0);
|
||||
EXPECT_TRUE(NULL!=strstr(output, custom));
|
||||
|
||||
free(input);
|
||||
free(output);
|
||||
output = NULL;
|
||||
}
|
||||
|
||||
int main(int argc, char ** argv)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user