| 105 | } |
| 106 | |
| 107 | bool IsSafeZipResourceName(const std::string& name) { |
| 108 | if (name.empty() || IsAbsolutePath(name)) { |
| 109 | return false; |
| 110 | } |
| 111 | size_t start = 0; |
| 112 | for (;;) { |
| 113 | const size_t pos = name.find('/', start); |
| 114 | const std::string part = name.substr(start, pos - start); |
| 115 | if (part.empty() || part == "." || part == "..") { |
| 116 | return false; |
| 117 | } |
| 118 | if (pos == std::string::npos) { |
| 119 | return true; |
| 120 | } |
| 121 | start = pos + 1; |
| 122 | } |
| 123 | } |
| 124 | |
| 125 | std::string BaseName(const std::string& path) { |
| 126 | const size_t pos = path.find_last_of('/'); |
no test coverage detected