aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2020-08-18 23:33:25 +0200
committerdec05eba <dec05eba@protonmail.com>2020-08-18 23:38:30 +0200
commitb72442a0362a266990b5a8f7431ec708de1ff006 (patch)
treec414c0d7ecede2bdd02f51cd5813af3e3ad73620
parent7713c01939b19b588e6e99d4b583447b9e2362f6 (diff)
WIP: FIX p2p
-rw-r--r--.gitmodules2
m---------depends/odhtdb0
-rw-r--r--include/dchat/Process.hpp2
-rw-r--r--src/Cache.cpp6
-rw-r--r--src/Process.cpp23
5 files changed, 11 insertions, 22 deletions
diff --git a/.gitmodules b/.gitmodules
index 8fd227f..e5fa433 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,3 +1,3 @@
[submodule "depends/odhtdb"]
path = depends/odhtdb
- url = https://gitlab.com/DEC05EBA/odhtdb.git
+ url = https://git.dec05eba.com/odhtdb
diff --git a/depends/odhtdb b/depends/odhtdb
-Subproject 9fbd841d853e1c6483a93e5c96aa589a26e2899
+Subproject e066fcddf15ee5ee4084a29c89a74bc89abb20d
diff --git a/include/dchat/Process.hpp b/include/dchat/Process.hpp
index 18aa2d9..af9d6c5 100644
--- a/include/dchat/Process.hpp
+++ b/include/dchat/Process.hpp
@@ -4,5 +4,5 @@
namespace dchat
{
- std::string escapeCommand(const std::string &cmd);
+ std::string escapeCommandArg(const std::string &cmd);
} \ No newline at end of file
diff --git a/src/Cache.cpp b/src/Cache.cpp
index bb87857..eecc790 100644
--- a/src/Cache.cpp
+++ b/src/Cache.cpp
@@ -351,9 +351,9 @@ namespace dchat
string downloadLimitBytesStr = to_string(downloadLimitBytes);
- std::string cmdUtf8 = "curl -L --silent -o '";
- cmdUtf8 += escapeCommand(filepath.string());
- cmdUtf8 += "' --max-filesize " + downloadLimitBytesStr + " --range 0-" + downloadLimitBytesStr + " --url '" + escapeCommand(url) + "'";
+ std::string cmdUtf8 = "curl -L --silent -o ";
+ cmdUtf8 += escapeCommandArg(filepath.string());
+ cmdUtf8 += " --max-filesize " + downloadLimitBytesStr + " --range 0-" + downloadLimitBytesStr + " --url " + escapeCommandArg(url);
Process::string_type cmd = toNativeString(cmdUtf8);
// TODO: Use this instead of curl on windows: certutil.exe -urlcache -split -f "https://url/to/file" path/and/name/to/save/as/file
Process *process = new Process(cmd, toNativeString(""), nullptr, nullptr, false);
diff --git a/src/Process.cpp b/src/Process.cpp
index d82da42..29eb5fc 100644
--- a/src/Process.cpp
+++ b/src/Process.cpp
@@ -2,32 +2,21 @@
namespace dchat
{
- std::string escapeCommand(const std::string &cmd)
+ std::string escapeCommandArg(const std::string &cmd)
{
std::string result;
result.reserve(cmd.size());
- bool escape = false;
+ result += "'";
for(char c : cmd)
{
- if(c == '\\')
- escape = !escape;
+ if(c == '\'')
+ result += "\"'\""; // "'"
else
- {
- if(escape)
- result += "\\";
-
- if(c == '"')
- result += "\\\""; // \"
- else if(c == '\'')
- result += "\\'"; // \'
- else
- result += c;
-
- escape = false;
- }
+ result += c;
}
+ result += "'";
return result;
}
} \ No newline at end of file