From 188bb2ec38196ab1fa8c34dd0c5ee496ebf3c585 Mon Sep 17 00:00:00 2001 From: emeric Date: Sun, 18 Nov 2018 15:28:12 +0100 Subject: [PATCH 1/3] Added missing French translations --- approot/messages_fr.xml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/approot/messages_fr.xml b/approot/messages_fr.xml index 0a2690f8..89ff1ce3 100644 --- a/approot/messages_fr.xml +++ b/approot/messages_fr.xml @@ -128,5 +128,12 @@ Invalide Mot de passe invalide +Trop court +Trop long +Pas assez de caractères ou de classes différentes pour cette longueur de mot de passe +Pas assez de caractères ou de classes différentes +Basé sur des informations personnelles +Basé sur un mot de dictionnaire +Basé sur une séquence de caractères From 925ad453f847edc9ab50b4668c04af943e4720b1 Mon Sep 17 00:00:00 2001 From: emeric Date: Thu, 29 Nov 2018 21:03:59 +0100 Subject: [PATCH 2/3] Prevent crash --- src/ui/admin/UsersView.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ui/admin/UsersView.cpp b/src/ui/admin/UsersView.cpp index fbddd2e2..b3e249d4 100644 --- a/src/ui/admin/UsersView.cpp +++ b/src/ui/admin/UsersView.cpp @@ -114,7 +114,8 @@ UsersView::refreshView() user.remove(); _container->removeWidget(entry); } - delBtn->removeChild(msgBox); + else + delBtn->removeChild(msgBox); }); msgBox->show(); From 05a2aa4aa106aa12b7dbca365a8f20750def7c2b Mon Sep 17 00:00:00 2001 From: emeric Date: Thu, 29 Nov 2018 21:04:49 +0100 Subject: [PATCH 3/3] Properly escape user messages (fix popup error) --- src/ui/LmsApplication.cpp | 7 ++++++- src/utils/Utils.cpp | 15 +++++++++++++++ src/utils/Utils.hpp | 3 +++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/ui/LmsApplication.cpp b/src/ui/LmsApplication.cpp index 2116765e..a37e2395 100644 --- a/src/ui/LmsApplication.cpp +++ b/src/ui/LmsApplication.cpp @@ -537,6 +537,11 @@ LmsApplication::post(std::function func) Wt::WServer::instance()->post(LmsApp->sessionId(), func); } +static std::string escape(std::string str) +{ + return replaceInString(std::move(str), "\'", "\\\'"); +} + void LmsApplication::notifyMsg(MsgType type, const Wt::WString& message, std::chrono::milliseconds duration) { @@ -545,7 +550,7 @@ LmsApplication::notifyMsg(MsgType type, const Wt::WString& message, std::chrono: std::ostringstream oss; oss << "$.notify({" - "message: '" << message.toUTF8() << "'" + "message: '" << escape(message.toUTF8()) << "'" "},{" "type: '" << msgTypeToString(type) << "'," "placement: {from: 'top', align: 'center'}," diff --git a/src/utils/Utils.cpp b/src/utils/Utils.cpp index f7864cb1..57704eac 100644 --- a/src/utils/Utils.cpp +++ b/src/utils/Utils.cpp @@ -102,3 +102,18 @@ bufferToString(const std::vector& data) return oss.str(); } +std::string +replaceInString(std::string str, const std::string& from, const std::string& to) +{ + size_t pos = 0; + + while ((pos = str.find(from, pos)) != std::string::npos) + { + str.replace(pos, from.length(), to); + pos += to.length(); + } + + return str; +} + + diff --git a/src/utils/Utils.hpp b/src/utils/Utils.hpp index cba5fe91..287a62e4 100644 --- a/src/utils/Utils.hpp +++ b/src/utils/Utils.hpp @@ -60,3 +60,6 @@ boost::optional readAs(const std::string& str) return res; } +std::string +replaceInString(std::string str, const std::string& from, const std::string& to); +