From d1bdf6917317ba9c3d878b175fe476e83de5317d Mon Sep 17 00:00:00 2001 From: Celtic Minstrel Date: Sun, 30 Apr 2017 16:54:52 -0400 Subject: [PATCH] Support @ or = in usernames Though I don't think these are allowed currently, it's probably better to support it from the start rather than having things break if they later become allowed. --- src/credentials.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/credentials.cpp b/src/credentials.cpp index ac5ec150be29..4f0fdd740422 100644 --- a/src/credentials.cpp +++ b/src/credentials.cpp @@ -176,8 +176,8 @@ namespace preferences return; } for(const std::string elem : utils::split(data, CREDENTIAL_SEPARATOR, utils::REMOVE_EMPTY)) { - size_t at = elem.find_first_of('@'); - size_t eq = elem.find_first_of('='); + size_t at = elem.find_last_of('@'); + size_t eq = elem.find_first_of('=', at + 1); if(at != std::string::npos && eq != std::string::npos) { credentials.emplace_back(elem.substr(0, at), elem.substr(at + 1, eq - at - 1), elem.substr(eq + 1)); } @@ -252,6 +252,8 @@ std::string unescape(const std::string& text) if(escaping) { if(c == '\xa') { unescaped.push_back('\xc'); + } else if(c == '.') { + unescaped.push_back('@'); } else { unescaped.push_back(c); } @@ -275,6 +277,8 @@ std::string escape(const std::string& text) escaped += "\x1\x1"; } else if(c == '\xc') { escaped += "\x1\xa"; + } else if(c == '@') { + escaped += "\x1."; } else { escaped.push_back(c); }