return out;
}
+/* Decoding of strings produced by uri_encode. */
+string uri_decode(const string &in)
+{
+ char *buf = new char[in.size() + 1];
+
+ const char *input = in.c_str();
+ char *output = buf;
+
+ while (*input != '\0') {
+ if (*input == '%') {
+ char hexbuf[4];
+ if (isxdigit(input[1]) && isxdigit(input[2])) {
+ hexbuf[0] = input[1];
+ hexbuf[1] = input[2];
+ hexbuf[2] = '\0';
+ *output++ = strtol(hexbuf, NULL, 16);
+ input += 3;
+ } else {
+ input++;
+ }
+ } else {
+ *output++ = *input++;
+ }
+ }
+
+ *output = '\0';
+
+ string result(buf);
+ delete buf;
+ return result;
+}
+
/* Return the string representation of an integer. */
string encode_int(long long n)
{
#include <string>
std::string uri_encode(const std::string &in);
+std::string uri_decode(const std::string &in);
std::string encode_int(long long n);
void dict_output(std::ostream &o, std::map<std::string, std::string> dict);
old_checksum = "";
old_contents.clear();
- /* First, read in the filename. TODO: Unescaping. */
+ /* First, read in the filename. */
getline(cache, old_name);
if (!cache) {
end_of_cache = true;
return;
}
+ old_name = uri_decode(old_name);
/* Start reading in the fields which follow the filename. */
string field = "";