The host of a URL value (after any user@, before :port). */
| 2185 | |
| 2186 | /* The host of a URL value (after any user@, before :port). */ |
| 2187 | static bool env_url_host(const char *v, char *host, size_t sz) { |
| 2188 | const char *q = v; |
| 2189 | if (!islower((unsigned char)*q)) { |
| 2190 | return false; |
| 2191 | } |
| 2192 | while (islower((unsigned char)*q) || isdigit((unsigned char)*q) || *q == '+' || *q == '.' || |
| 2193 | *q == '-') { |
| 2194 | q++; |
| 2195 | } |
| 2196 | if (strncmp(q, "://", strlen("://")) != 0) { |
| 2197 | return false; |
| 2198 | } |
| 2199 | const char *h = q + strlen("://"); |
| 2200 | size_t hl = strcspn(h, "/ \t\r\n\"'"); |
| 2201 | for (size_t i = hl; i > 0; i--) { |
| 2202 | if (h[i - SKIP_ONE] == '@') { |
| 2203 | hl -= i; |
| 2204 | h += i; |
| 2205 | break; |
| 2206 | } |
| 2207 | } |
| 2208 | size_t colon = strcspn(h, ":"); |
| 2209 | return env_copy(host, sz, h, colon < hl ? colon : hl); |
| 2210 | } |
| 2211 | |
| 2212 | /* `host:port` with a 2-5 digit port. */ |
| 2213 | static bool env_hostport(const char *v, char *host, size_t sz) { |
no test coverage detected