| 77 | static char g_cors_json[512]; /* CORS + Content-Type: application/json */ |
| 78 | |
| 79 | static bool origin_is_same_server(const char *origin, int port) { |
| 80 | char expected[128]; |
| 81 | int length = snprintf(expected, sizeof(expected), "http://127.0.0.1:%d", port); |
| 82 | if (length > 0 && (size_t)length < sizeof(expected) && strcmp(origin, expected) == 0) |
| 83 | return true; |
| 84 | length = snprintf(expected, sizeof(expected), "http://localhost:%d", port); |
| 85 | return length > 0 && (size_t)length < sizeof(expected) && strcmp(origin, expected) == 0; |
| 86 | } |
| 87 | |
| 88 | static bool origin_matches_host(const char *origin, const char *host, int port) { |
| 89 | /* Two literal loopback forms only — spelled out so the static URL audit |
no outgoing calls
no test coverage detected