MCPcopy Create free account
hub / github.com/BYVoid/OpenCC / IsSafeZipResourceName

Function IsSafeZipResourceName

src/ResourceProvider.cpp:107–123  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

105}
106
107bool 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
125std::string BaseName(const std::string& path) {
126 const size_t pos = path.find_last_of('/');

Callers 2

IndexMethod · 0.85
GetResourceMethod · 0.85

Calls 4

findMethod · 0.80
IsAbsolutePathFunction · 0.70
emptyMethod · 0.45
substrMethod · 0.45

Tested by

no test coverage detected