Skip to content

Commit

Permalink
修复object_key检查逻辑 (#60)
Browse files Browse the repository at this point in the history
* 修复object_key检查逻辑

---------

Co-authored-by: huberyxxiao <[email protected]>
  • Loading branch information
Huberyxiao and huberyxxiao authored Jul 8, 2024
1 parent 8b1018b commit 540f640
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
3 changes: 1 addition & 2 deletions cos_c_sdk/cos_sys_define.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,7 @@ typedef apr_array_header_t cos_array_header_t;
#define CR (char) 13
#define CRLF "\x0d\x0a"


#define COS_VERSION "5.0.19"
#define COS_VERSION "5.0.20"
#define COS_VER "cos-sdk-c/" COS_VERSION

#define COS_HTTP_PREFIX "http://"
Expand Down
13 changes: 11 additions & 2 deletions cos_c_sdk/cos_utility.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ int is_should_retry_endpoint(const cos_status_t *s, const char *str){
}
#endif


int check_status_with_resp_body(cos_list_t *body, int64_t body_len,const char *target){
cos_list_t *current = body->next;
int target_len = strlen(target);
Expand Down Expand Up @@ -214,11 +213,20 @@ char ** split(const char * s, char delim, int * returnSize) {
return ans;
}

int object_key_simplify_check(const char * path){
int object_key_simplify_check(const char * object_path){
if (!get_object_key_simplify_check()){
return 1;
}
int namesSize = 0;
char *path;
if (object_path[0] == '/'){
path = (char *)malloc(sizeof(char *) * (strlen(object_path) + 1));
strcpy(path, object_path);
}else {
path = (char *)malloc(sizeof(char *) * (strlen(object_path) + 2));
path[0] = '/';
strcpy(path + 1, object_path);
}
int n = strlen(path);
char ** names = split(path, '/', &namesSize);
char ** stack = (char **)malloc(sizeof(char *) * namesSize);
Expand Down Expand Up @@ -254,6 +262,7 @@ int object_key_simplify_check(const char * path){
}
free(names);
free(stack);
free(path);
if (strlen(ans) == 1 && ans[0] == '/'){
free(ans);
return 0;
Expand Down

0 comments on commit 540f640

Please sign in to comment.