From fc22bbc1e0268f602db1b23714a7fa4b0d2f620b Mon Sep 17 00:00:00 2001 From: Dario Date: Tue, 25 Feb 2020 14:53:54 +0100 Subject: [PATCH] update password reset --- src/cpp/Crypto/KeyPair.cpp | 41 +++++++++++++++++++++--- src/cpp/HTTPInterface/PassphrasePage.cpp | 2 +- src/cpsp/passphrase.cpsp | 2 +- 3 files changed, 39 insertions(+), 6 deletions(-) diff --git a/src/cpp/Crypto/KeyPair.cpp b/src/cpp/Crypto/KeyPair.cpp index 61d98470f..f435e166c 100644 --- a/src/cpp/Crypto/KeyPair.cpp +++ b/src/cpp/Crypto/KeyPair.cpp @@ -6,6 +6,8 @@ #include "../SingletonManager/ErrorManager.h" #include "../SingletonManager/ConnectionManager.h" +//#include "Poco/ISO8859_4Encoding.h" + using namespace Poco::Data::Keywords; @@ -154,14 +156,43 @@ std::string KeyPair::filterPassphrase(const std::string& passphrase) std::string filteredPassphrase; auto passphrase_size = passphrase.size(); for (int i = 0; i < passphrase_size; i++) { - char c = passphrase.data()[i]; + unsigned char c = passphrase.data()[i]; // asci 128 even by utf8 (hex) // 0000 0000 – 0000 007F // utf8 if (c > 0x0000007F) { int additionalUtfByteCount = 0; - filteredPassphrase += c; + //filteredPassphrase += c; if ((c & 0x00000080) == 0x00000080) { + // c3 a4 => ä + // c3 bc => ü + // c3 b6 => ö + // c3 84 => Ä + // c3 96 => Ö + // c3 9c => Ü + // c3 9f => ß + + std::vector> specialChars = { + {0xa4, "auml"}, {0x84, "Auml"}, + {0xbc, "uuml"}, {0x9c, "Uuml"}, + {0xb6, "ouml"}, {0x96, "Ouml"}, + {0x9f, "szlig"} + }; + + unsigned char c2 = passphrase.data()[i + 1]; + bool insertedHtmlEntitie = false; + for (auto it = specialChars.begin(); it != specialChars.end(); it++) { + if (c2 == it->get<0>()) { + auto htmlEntitie = it->get<1>(); + filteredPassphrase += "&"; + filteredPassphrase += htmlEntitie; + filteredPassphrase += ";"; + i++; + insertedHtmlEntitie = true; + break; + } + } + if (insertedHtmlEntitie) continue; additionalUtfByteCount = 1; } else if ((c & 0x00000800) == 0x00000800) { @@ -170,7 +201,7 @@ std::string KeyPair::filterPassphrase(const std::string& passphrase) else if ((c & 0x00010000) == 0x00010000) { additionalUtfByteCount = 3; } - for (int j = 1; j <= additionalUtfByteCount; j++) { + for (int j = 0; j <= additionalUtfByteCount; j++) { filteredPassphrase += passphrase.data()[i + j]; i++; } @@ -181,7 +212,9 @@ std::string KeyPair::filterPassphrase(const std::string& passphrase) // 90 = Z // 97 = a // 122 = z - if (c == 32 || + // 59 = ; + // 38 = & + if (c == 32 || c == 59 || c == 38 || (c >= 65 && c <= 90) || (c >= 97 && c <= 122)) { filteredPassphrase += c; diff --git a/src/cpp/HTTPInterface/PassphrasePage.cpp b/src/cpp/HTTPInterface/PassphrasePage.cpp index d48a47441..5a4347a4d 100644 --- a/src/cpp/HTTPInterface/PassphrasePage.cpp +++ b/src/cpp/HTTPInterface/PassphrasePage.cpp @@ -511,7 +511,7 @@ void PassphrasePage::handleRequest(Poco::Net::HTTPServerRequest& request, Poco:: responseStream << "\t
\n"; responseStream << "\t\t
\n"; responseStream << "\t\t
\n"; - responseStream << "\t\t\t
\n"; + responseStream << "\t\t\t
\n"; responseStream << "\t\t\t
"; #line 251 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\passphrase.cpsp" responseStream << ( gettext("Konto wiederherstellen / Neues Passwort anlegen") ); diff --git a/src/cpsp/passphrase.cpsp b/src/cpsp/passphrase.cpsp index 9bdd95b38..9979b71ea 100644 --- a/src/cpsp/passphrase.cpsp +++ b/src/cpsp/passphrase.cpsp @@ -247,7 +247,7 @@ enum PageState
-
+
<%= gettext("Konto wiederherstellen / Neues Passwort anlegen") %>

<%= gettext("Um dein Konto wiederherzustellen, dir ein Neues Passwort auswählen zu können, tippe hier bitte die Wörter deiner Passphrase in der richtigen Reihenfolge ein, welche du dir aufgeschrieben hast.") %>