summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugins/NewStory/src/templates.cpp4
-rw-r--r--protocols/Telegram/src/utils.cpp23
2 files changed, 18 insertions, 9 deletions
diff --git a/plugins/NewStory/src/templates.cpp b/plugins/NewStory/src/templates.cpp
index 20564773b1..0f6cc4eb66 100644
--- a/plugins/NewStory/src/templates.cpp
+++ b/plugins/NewStory/src/templates.cpp
@@ -175,7 +175,9 @@ static void AppendString(CMStringW &buf, const wchar_t *p, ItemData *pItem)
if (auto *p2 = wcsstr(p1, L"[/url]")) {
CMStringW wszDescr(p1, int(p2 - p1));
- buf.AppendFormat(L"<a class=\"link\" href=\"%s\">%s</a>", wszUrl.c_str(), wszDescr.c_str());
+ buf.AppendFormat(L"<a class=\"link\" href=\"%s\">", wszUrl.c_str());
+ AppendString(buf, wszDescr, pItem);
+ buf.Append(L"</a>");
p = p2 + 5;
}
}
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<TD::formattedText> &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<HistItem> history;
@@ -119,19 +118,27 @@ CMStringA CTelegramProto::GetFormattedText(TD::object_ptr<TD::formattedText> &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();
}