From 7627c1bdd4aa2ce06d0a68495e6d5ee1feb07e70 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 19 Apr 2025 15:31:07 +0300 Subject: =?UTF-8?q?fixes=20#4994=20(Telegram:=20=D0=BF=D1=80=D0=BE=D0=B1?= =?UTF-8?q?=D0=BB=D0=B5=D0=BC=D0=B0=20=D1=81=20=D1=82=D0=B5=D0=B3=D0=B0?= =?UTF-8?q?=D0=BC=D0=B8=20=D0=BF=D1=80=D0=B8=20=D0=BF=D0=B5=D1=80=D0=B5?= =?UTF-8?q?=D1=81=D1=8B=D0=BB=D0=BA=D0=B5=20=D1=81=D0=BE=D0=BE=D0=B1=D1=89?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D1=8F)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- protocols/Telegram/src/utils.cpp | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'protocols/Telegram/src/utils.cpp') diff --git a/protocols/Telegram/src/utils.cpp b/protocols/Telegram/src/utils.cpp index 9ae6d8f9cb..13983cb2b2 100644 --- a/protocols/Telegram/src/utils.cpp +++ b/protocols/Telegram/src/utils.cpp @@ -96,9 +96,8 @@ CMStringA CTelegramProto::GetFormattedText(TD::object_ptr &pT CMStringW ret(Utf2T(pText->text_.c_str())); struct HistItem { - HistItem(int _1, int _2, const Bbcode &_3) : start(_1), length(_2), bbcode(_3) {} - int start, length; - const Bbcode &bbcode; + HistItem(int _1, int _2, const Bbcode &_3) : start(_1), length(_2), l1(_3.len1), l2(_3.len2) {} + int start, length, l1, l2; }; std::vector history; @@ -119,19 +118,27 @@ CMStringA CTelegramProto::GetFormattedText(TD::object_ptr &pT int off1 = 0, off2 = 0; for (auto &h : history) { if (it->offset_ >= h.start) - off1 += h.bbcode.len1; + off1 += h.l1; if (it->offset_ + it->length_ > h.start) - off2 += h.bbcode.len1; + off2 += h.l1; if (it->offset_ >= h.start + h.length) - off1 += h.bbcode.len2; + off1 += h.l2; if (it->offset_ + it->length_ > h.start + h.length) - off2 += h.bbcode.len2; + off2 += h.l2; } auto &bb = bbCodes[iCode]; + HistItem histItem(it->offset_, it->length_, bb); ret.Insert(off2 + it->offset_ + it->length_, bb.end); ret.Insert(off1 + it->offset_, bb.begin); - history.push_back(HistItem(it->offset_, it->length_, bb)); + if (iCode == 4) { + auto *pUrl = (TD::textEntityTypeTextUrl *)it->type_.get(); + Utf2T wszUrl(pUrl->url_.c_str()); + ret.Insert(off1 + it->offset_ + 4, wszUrl); + ret.Insert(off1 + it->offset_ + 4, L"="); + histItem.l1 += 1 + (int)mir_wstrlen(wszUrl); + } + history.push_back(histItem); } return T2Utf(ret).get(); } -- cgit v1.2.3