From 131d8e564e452dfcce00bb07e1f67cc8b8e3eb67 Mon Sep 17 00:00:00 2001 From: John Brooks Date: Sun, 6 Jul 2014 16:35:49 +0200 Subject: [PATCH] core: Fix contact ID parsing with new URI name Regression from 3f3b857, which prevented adding new contacts. --- src/core/ContactIDValidator.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/core/ContactIDValidator.cpp b/src/core/ContactIDValidator.cpp index ade7c554..0d09d1d3 100644 --- a/src/core/ContactIDValidator.cpp +++ b/src/core/ContactIDValidator.cpp @@ -32,7 +32,7 @@ #include "ContactIDValidator.h" -static QRegularExpression regex(QStringLiteral("(torsion|ricochet):[a-z2-7]{16}")); +static QRegularExpression regex(QStringLiteral("(torsion|ricochet):([a-z2-7]{16})")); ContactIDValidator::ContactIDValidator(QObject *parent) : QRegularExpressionValidator(parent), m_uniqueIdentity(0) @@ -72,7 +72,7 @@ ContactUser *ContactIDValidator::matchingContact(const QString &text) const bool ContactIDValidator::matchesIdentity(const QString &text) const { - return m_uniqueIdentity && m_uniqueIdentity->contactID() == text; + return m_uniqueIdentity && m_uniqueIdentity->hostname() == hostnameFromID(text); } void ContactIDValidator::fixup(QString &text) const @@ -87,10 +87,11 @@ bool ContactIDValidator::isValidID(const QString &text) QString ContactIDValidator::hostnameFromID(const QString &ID) { - if (!isValidID(ID)) + QRegularExpressionMatch match = regex.match(ID); + if (!match.hasMatch()) return QString(); - return ID.mid(8) + QStringLiteral(".onion"); + return match.captured(2) + QStringLiteral(".onion"); } QString ContactIDValidator::idFromHostname(const QString &hostname)