| 731 | } |
| 732 | |
| 733 | static bool has_filesystem_extension(const char *path) { |
| 734 | if (!path) { |
| 735 | return false; |
| 736 | } |
| 737 | const char *end = strpbrk(path, "?#"); |
| 738 | if (!end) { |
| 739 | end = path + strlen(path); |
| 740 | } |
| 741 | const char *last_slash = path; |
| 742 | for (const char *p = path; p < end; p++) { |
| 743 | if (*p == '/') { |
| 744 | last_slash = p; |
| 745 | } |
| 746 | } |
| 747 | const char *dot = NULL; |
| 748 | for (const char *p = last_slash + 1; p < end; p++) { |
| 749 | if (*p == '.') { |
| 750 | dot = p; |
| 751 | } |
| 752 | } |
| 753 | if (!dot || dot == end - 1) { |
| 754 | return false; |
| 755 | } |
| 756 | char ext[32]; |
| 757 | size_t ext_len = (size_t)(end - dot); |
| 758 | if (ext_len >= sizeof(ext)) { |
| 759 | return false; |
| 760 | } |
| 761 | memcpy(ext, dot, ext_len); |
| 762 | ext[ext_len] = '\0'; |
| 763 | |
| 764 | static const char *const hard_file_exts[] = { |
| 765 | ".cfg", ".conf", ".credentials", ".crt", ".db", ".env", ".ini", ".key", |
| 766 | ".log", ".md", ".pdf", ".pem", ".pid", ".properties", ".rst", ".service", |
| 767 | ".sock", ".socket", ".sqlite", ".toml", ".txt", NULL}; |
| 768 | for (int i = 0; hard_file_exts[i]; i++) { |
| 769 | if (path_ext_matches(ext, hard_file_exts[i])) { |
| 770 | return true; |
| 771 | } |
| 772 | } |
| 773 | if ((path_ext_matches(ext, ".json") || path_ext_matches(ext, ".yaml") || |
| 774 | path_ext_matches(ext, ".yml") || path_ext_matches(ext, ".xml")) && |
| 775 | !has_http_route_marker(path)) { |
| 776 | return true; |
| 777 | } |
| 778 | return false; |
| 779 | } |
| 780 | |
| 781 | static bool callee_is_delimiter_or_filesystem_builder(const char *callee_name) { |
| 782 | if (!callee_name) { |
no test coverage detected