Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check more protocols while adding link #28407

Merged
merged 2 commits into from
Sep 26, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading