From 6323accef266d9f3ab12d252f4e8514f27a29f11 Mon Sep 17 00:00:00 2001 From: Julien Wadel Date: Mon, 27 Mar 2023 11:14:54 +0200 Subject: [PATCH] Fix using only username in URI handlers. --- CHANGELOG.md | 22 ++++++++++++++----- linphone-app/src/app/cli/Cli.cpp | 16 ++++++++++---- linphone-app/src/utils/Utils.cpp | 6 +++++ linphone-app/src/utils/Utils.hpp | 1 + .../ui/modules/Linphone/Calls/Calls.qml | 8 ++++--- 5 files changed, 41 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 54aa5765c..8a3fe751d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,17 +18,28 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Display last seen for contacts. - New language support: Czech -### Fixed -- Update SDK to 5.2.29 +## 5.0.15 - undefined -## 5.0.13 - undefined +## Fixed +- Fix using only username in URI handlers. + +## 5.0.14 - 2023-03-16 + +## Fixed +- Downgrade Qt back to 5.15.2 because of Qt commercial licence that break other GPL licences. +- Show file extension image instead of thumbnails if image's size factor is too low/high. +- Update SDK to 5.2.35 (ZLib vulnerability). + +## 5.0.13 - 2023-03-13 - postprone to 5.0.14 ### Fixed - Conference layout refreshing on creation. - Crash and display of local conferences. - Crash on chat rooms with default account. +- Show display name for local accounts. +- Update SDK to 5.2.32 -## 5.0.12 - 2023-03-01 +## 5.0.12 - 2023-03-01 - postprone to 5.0.14 ### Fixed - Some case of unwanted settings folders creation. @@ -36,7 +47,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Unusable Contact sheet. - Update SDK to 5.2.28 (cleanup orphan NAT sections and race condition on MSTicker threads). -## 5.0.11 - 2023-02-24 +## 5.0.11 - 2023-02-24 - postprone to 5.0.14 + ### Fixed - Display of non-Ascii avatar diff --git a/linphone-app/src/app/cli/Cli.cpp b/linphone-app/src/app/cli/Cli.cpp index 1affbc763..941db718e 100644 --- a/linphone-app/src/app/cli/Cli.cpp +++ b/linphone-app/src/app/cli/Cli.cpp @@ -359,6 +359,8 @@ void Cli::Command::execute (QHash &args) const { void Cli::Command::executeUri (const shared_ptr &address) const { QHash args; QString qAddress = Utils::coreStringToAppString(address->asString()); + if(address->getDomain() == "" && qAddress.back() == '@') + qAddress.remove(qAddress.size()-1, 1); QUrl url(qAddress); QString query = url.query(); @@ -378,7 +380,7 @@ void Cli::Command::executeUri (const shared_ptr &address) con const string header = address->getHeader(Utils::appStringToCoreString(argName)); args[argName] = QByteArray::fromBase64(QByteArray(header.c_str(), int(header.length()))); } - args["sip-address"] = Utils::coreStringToAppString(address->asString()); + args["sip-address"] = qAddress; execute(args); } @@ -526,15 +528,21 @@ void Cli::executeCommand (const QString &command, CommandFormat *format) { *format = CliFormat; mCommands["show"].execute(args); }else{ - shared_ptr address = linphone::Factory::get()->createAddress(Utils::appStringToCoreString(transformedCommand));// Test if command is an address + shared_ptr address; + if(Utils::isUsername(transformedCommand)){ + address = linphone::Factory::get()->createAddress(Utils::appStringToCoreString(transformedCommand+"@to.remove")); + if(address) + address->setDomain(""); + }else + address = linphone::Factory::get()->createAddress(Utils::appStringToCoreString(transformedCommand));// Test if command is an address if (format) *format = UriFormat; qInfo() << QStringLiteral("Detecting URI command: `%1`...").arg(command); QString functionName; if( address) { functionName = Utils::coreStringToAppString(address->getHeader("method")).isEmpty() - ? QStringLiteral("call") - : Utils::coreStringToAppString(address->getHeader("method")); + ? QStringLiteral("call") + : Utils::coreStringToAppString(address->getHeader("method")); }else{ QStringList fields = command.split('?'); if(fields.size() >1){ diff --git a/linphone-app/src/utils/Utils.cpp b/linphone-app/src/utils/Utils.cpp index d938f1201..c6866c6a3 100644 --- a/linphone-app/src/utils/Utils.cpp +++ b/linphone-app/src/utils/Utils.cpp @@ -655,6 +655,12 @@ bool Utils::isPhoneNumber(const QString& txt){ return account && account->isPhoneNumber(Utils::appStringToCoreString(txt)); } +bool Utils::isUsername(const QString& txt){ + QRegularExpression regex("^(?$"); + QRegularExpressionMatch match = regex.match(txt); + return match.hasMatch(); // true +} + QSize Utils::getImageSize(const QString& url){ QString path; QUrl urlDecode(url); diff --git a/linphone-app/src/utils/Utils.hpp b/linphone-app/src/utils/Utils.hpp index b14104e9b..1e6b846bd 100644 --- a/linphone-app/src/utils/Utils.hpp +++ b/linphone-app/src/utils/Utils.hpp @@ -72,6 +72,7 @@ public: Q_INVOKABLE static bool isPdf(const QString& path); Q_INVOKABLE static bool isSupportedForDisplay(const QString& path); Q_INVOKABLE static bool isPhoneNumber(const QString& txt); + Q_INVOKABLE static bool isUsername(const QString& txt); // Check with Regex Q_INVOKABLE QSize getImageSize(const QString& url); Q_INVOKABLE static QPoint getCursorPosition(); Q_INVOKABLE static QString getFileChecksum(const QString& filePath); diff --git a/linphone-app/ui/modules/Linphone/Calls/Calls.qml b/linphone-app/ui/modules/Linphone/Calls/Calls.qml index 191796556..2a6f914fb 100644 --- a/linphone-app/ui/modules/Linphone/Calls/Calls.qml +++ b/linphone-app/ui/modules/Linphone/Calls/Calls.qml @@ -148,9 +148,11 @@ ListView { // ------------------------------------------------------------------------- property var entryColors: CallsStyle.entry.color - color: isDarkMode - ? entryColors.selected.color - : entryColors.normal.color + color: entryColors + ? isDarkMode + ? entryColors.selected.color + : entryColors.normal.color + : CallsStyle.entry.color.normal.color subtitleColor: isDarkMode ? CallsStyle.entry.subtitleColor.selected.color : CallsStyle.entry.subtitleColor.normal.color