Skip to content

Commit

Permalink
Check more protocols while adding link
Browse files Browse the repository at this point in the history
  • Loading branch information
xmdnx authored Sep 13, 2024
1 parent 98ba2c7 commit 1646bdd
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions Telegram/SourceFiles/chat_helpers/message_field.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ constexpr auto kParseLinksTimeout = crl::time(1000);
constexpr auto kTypesDuration = 4 * crl::time(1000);
constexpr auto kCodeLanguageLimit = 32;

constexpr auto kLinkProtocols = {
"http://",
"https://",
"tonsite://"
};

// For mention / custom emoji tags save and validate selfId,
// ignore tags for different users.
[[nodiscard]] Fn<QString(QStringView)> FieldTagMimeProcessor(
Expand Down Expand Up @@ -152,11 +158,12 @@ void EditLinkBox(
return startLink.trimmed();
}
const auto clipboard = QGuiApplication::clipboard()->text().trimmed();
if (clipboard.startsWith("http://")
|| clipboard.startsWith("https://")) {
return clipboard;
}
return QString();
return std::ranges::any_of(
kLinkProtocols,
[&] (const auto &protocol) {
return clipboard.startsWith(protocol);
}
) ? clipboard : QString();
}();
const auto url = Ui::AttachParentChild(
content,
Expand Down

0 comments on commit 1646bdd

Please sign in to comment.