Unescape the escaped string we get from the WebExtension.
This commit is contained in:
parent
b79dacf742
commit
1c2828369d
|
@ -14,6 +14,8 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// TODO: Rewrite this in understandable code.
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
@ -30,7 +32,7 @@ using std::system;
|
||||||
string read_input();
|
string read_input();
|
||||||
void send_message(const string &message);
|
void send_message(const string &message);
|
||||||
int launch(const string &args);
|
int launch(const string &args);
|
||||||
string decode_args(const string &args);
|
string decode_args(string args);
|
||||||
void replace_in_field(string &field);
|
void replace_in_field(string &field);
|
||||||
|
|
||||||
string read_input()
|
string read_input()
|
||||||
|
@ -80,9 +82,17 @@ int launch(const string &args)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
string decode_args(const string &args)
|
string decode_args(string args)
|
||||||
{
|
{
|
||||||
constexpr char separator{'\u001F'}; // UNIT SEPARATOR.
|
{ // The string we get is escaped.
|
||||||
|
size_t pos{0};
|
||||||
|
while ((pos = args.find(R"(\u001f)", pos)) != string::npos)
|
||||||
|
{
|
||||||
|
args.replace(pos, 6, "\u001f");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr char separator{'\u001f'}; // UNIT SEPARATOR.
|
||||||
if (args[0] != separator) // Extension uses old method.
|
if (args[0] != separator) // Extension uses old method.
|
||||||
{
|
{
|
||||||
return args;
|
return args;
|
||||||
|
@ -112,6 +122,7 @@ void replace_in_field(string &field)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
const string args = read_input();
|
const string args = read_input();
|
||||||
|
|
Loading…
Reference in New Issue