forked from lix-project/lix
Support escaping in store URIs
This commit is contained in:
parent
4e7d5f660c
commit
848a9375c3
1 changed files with 18 additions and 2 deletions
|
@ -844,8 +844,24 @@ ref<Store> openStore(const std::string & uri_,
|
||||||
if (q != std::string::npos) {
|
if (q != std::string::npos) {
|
||||||
for (auto s : tokenizeString<Strings>(uri.substr(q + 1), "&")) {
|
for (auto s : tokenizeString<Strings>(uri.substr(q + 1), "&")) {
|
||||||
auto e = s.find('=');
|
auto e = s.find('=');
|
||||||
if (e != std::string::npos)
|
if (e != std::string::npos) {
|
||||||
params[s.substr(0, e)] = s.substr(e + 1);
|
auto value = s.substr(e + 1);
|
||||||
|
std::string decoded;
|
||||||
|
for (size_t i = 0; i < value.size(); ) {
|
||||||
|
if (value[i] == '%') {
|
||||||
|
if (i + 2 >= value.size())
|
||||||
|
throw Error("invalid URI parameter '%s'", value);
|
||||||
|
try {
|
||||||
|
decoded += std::stoul(std::string(value, i + 1, 2), 0, 16);
|
||||||
|
i += 3;
|
||||||
|
} catch (...) {
|
||||||
|
throw Error("invalid URI parameter '%s'", value);
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
decoded += value[i++];
|
||||||
|
}
|
||||||
|
params[s.substr(0, e)] = decoded;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
uri = uri_.substr(0, q);
|
uri = uri_.substr(0, q);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue