Don't expand urls same as text.
This commit is contained in:
parent
ae340a0b76
commit
663e2cc133
3 changed files with 18 additions and 7 deletions
|
|
@ -41,13 +41,16 @@ QString UrlClickHandler::copyToClipboardContextItemText() const {
|
||||||
: Ui::Integration::Instance().phraseContextCopyLink();
|
: Ui::Integration::Instance().phraseContextCopyLink();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString UrlClickHandler::url() const {
|
QString UrlClickHandler::EncodeForOpening(const QString &originalUrl) {
|
||||||
if (isEmail()) {
|
if (IsEmail(originalUrl)) {
|
||||||
return _originalUrl;
|
return originalUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
QUrl u(_originalUrl), good(u.isValid() ? u.toEncoded() : QString());
|
const auto u = QUrl(originalUrl);
|
||||||
QString result(good.isValid() ? QString::fromUtf8(good.toEncoded()) : _originalUrl);
|
const auto good = QUrl(u.isValid() ? u.toEncoded() : QString());
|
||||||
|
const auto result = good.isValid()
|
||||||
|
? QString::fromUtf8(good.toEncoded())
|
||||||
|
: originalUrl;
|
||||||
|
|
||||||
if (!result.isEmpty()
|
if (!result.isEmpty()
|
||||||
&& !QRegularExpression(
|
&& !QRegularExpression(
|
||||||
|
|
|
||||||
|
|
@ -59,11 +59,17 @@ public:
|
||||||
const auto at = url.indexOf('@'), slash = url.indexOf('/');
|
const auto at = url.indexOf('@'), slash = url.indexOf('/');
|
||||||
return ((at > 0) && (slash < 0 || slash > at));
|
return ((at > 0) && (slash < 0 || slash > at));
|
||||||
}
|
}
|
||||||
|
[[nodiscard]] static QString EncodeForOpening(const QString &originalUrl);
|
||||||
[[nodiscard]] static bool IsSuspicious(const QString &url);
|
[[nodiscard]] static bool IsSuspicious(const QString &url);
|
||||||
[[nodiscard]] static QString ShowEncoded(const QString &url);
|
[[nodiscard]] static QString ShowEncoded(const QString &url);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QString url() const override;
|
[[nodiscard]] QString originalUrl() const {
|
||||||
|
return _originalUrl;
|
||||||
|
}
|
||||||
|
QString url() const override {
|
||||||
|
return EncodeForOpening(_originalUrl);
|
||||||
|
}
|
||||||
QString readable() const override {
|
QString readable() const override {
|
||||||
return _readable;
|
return _readable;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3270,7 +3270,9 @@ TextForMimeData String::toText(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const auto skipLink = (entity.type == EntityType::CustomUrl)
|
const auto skipLink = (entity.type == EntityType::CustomUrl)
|
||||||
&& (entity.data.startsWith(qstr("internal:")));
|
&& (entity.data.startsWith(qstr("internal:"))
|
||||||
|
|| (entity.data
|
||||||
|
== UrlClickHandler::EncodeForOpening(full.toString())));
|
||||||
if (composeExpanded) {
|
if (composeExpanded) {
|
||||||
result.expanded.append(full);
|
result.expanded.append(full);
|
||||||
if (entity.type == EntityType::CustomUrl && !skipLink) {
|
if (entity.type == EntityType::CustomUrl && !skipLink) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue