Changeset a35b458 in mainline for uspace/lib/uri/uri.c
- Timestamp:
- 2018-03-02T20:10:49Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f1380b7
- Parents:
- 3061bc1
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:38:31)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:10:49)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/uri/uri.c
r3061bc1 ra35b458 56 56 return NULL; 57 57 memset(uri, 0, sizeof(uri_t)); 58 58 59 59 /* scheme ":" */ 60 60 const char *scheme = str; … … 65 65 } 66 66 uri->scheme = cut_str(scheme, str); 67 67 68 68 /* skip the colon */ 69 69 str++; 70 70 71 71 if (*str == '/' && str[1] == '/') { 72 72 /* "//" [user-info [":" user-credential] "@"] host [":" port] */ … … 74 74 str++; 75 75 const char *authority_start = str; 76 76 77 77 char *host_or_user_info = NULL; 78 78 char *port_or_user_credential = NULL; 79 79 80 80 while (*str != 0 && *str != '?' && *str != '#' && *str != '@' 81 81 && *str != ':' && *str != '/') 82 82 str++; 83 83 84 84 host_or_user_info = cut_str(authority_start, str); 85 85 if (*str == ':') { … … 90 90 port_or_user_credential = cut_str(second_part, str); 91 91 } 92 92 93 93 if (*str == '@') { 94 94 uri->user_info = host_or_user_info; 95 95 uri->user_credential = port_or_user_credential; 96 96 97 97 str++; 98 98 const char *host_start = str; … … 100 100 && *str != ':' && *str != '/') str++; 101 101 uri->host = cut_str(host_start, str); 102 102 103 103 if (*str == ':') { 104 104 str++; … … 114 114 } 115 115 } 116 116 117 117 const char *path_start = str; 118 118 while (*str != 0 && *str != '?' && *str != '#') str++; 119 119 uri->path = cut_str(path_start, str); 120 120 121 121 if (*str == '?') { 122 122 str++; … … 125 125 uri->query = cut_str(query_start, str); 126 126 } 127 127 128 128 if (*str == '#') { 129 129 str++; … … 132 132 uri->fragment = cut_str(fragment_start, str); 133 133 } 134 134 135 135 assert(*str == 0); 136 136 return uri; … … 149 149 return ELIMIT; 150 150 } 151 151 152 152 if (!isalpha(*str)) { 153 153 *endptr = str; 154 154 return EINVAL; 155 155 } 156 156 157 157 while (isalpha(*str) || isdigit(*str) || 158 158 *str == '+' || *str == '-' || *str == '.') { 159 159 str++; 160 160 } 161 161 162 162 *endptr = str; 163 163 return EOK; … … 181 181 if (str[0] == 0 || str[1] == 0 || str[2] == 0) 182 182 return ELIMIT; 183 183 184 184 if (str[0] != '%' || !is_hexdig(str[1]) || !is_hexdig(str[2])) 185 185 return EINVAL; 186 186 187 187 if (decoded != NULL) { 188 188 errno_t rc = str_uint8_t(str + 1, NULL, 16, true, decoded); … … 190 190 return rc; 191 191 } 192 192 193 193 *endptr = str + 3; 194 194 return EOK; … … 207 207 } 208 208 } 209 209 210 210 *endptr = str; 211 211 return EOK; … … 243 243 if (uri->scheme && !uri_scheme_validate(uri->scheme)) 244 244 return false; 245 245 246 246 if (uri->user_info && !uri_user_info_validate(uri->user_info)) 247 247 return false; 248 248 249 249 if (uri->user_credential && !uri_user_info_validate(uri->user_credential)) 250 250 return false; 251 251 252 252 if (uri->port && !uri_port_validate(uri->port)) 253 253 return false; 254 254 255 255 return true; 256 256 }
Note:
See TracChangeset
for help on using the changeset viewer.