URL-decode fragment to find matching anchor.
This commit is contained in:
parent
cd9a89fd7d
commit
bb9bb91c9c
@ -124,14 +124,22 @@ class RichText {
|
|||||||
context->has_anchor_urls_ = true;
|
context->has_anchor_urls_ = true;
|
||||||
} else {
|
} else {
|
||||||
auto anchor = Slice(content).substr(context->base_url_.size() + 1);
|
auto anchor = Slice(content).substr(context->base_url_.size() + 1);
|
||||||
auto it = context->anchors_.find(anchor);
|
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#the-indicated-part-of-the-document
|
||||||
if (it != context->anchors_.end()) {
|
for (int i = 0; i < 2; i++) {
|
||||||
if (it->second == nullptr) {
|
string url_decoded_anchor;
|
||||||
return make_tl_object<td_api::richTextAnchorLink>(texts[0].get_rich_text_object(context), anchor.str(),
|
if (i == 1) { // try to url_decode anchor
|
||||||
content);
|
url_decoded_anchor = url_decode(anchor, false);
|
||||||
} else {
|
anchor = url_decoded_anchor;
|
||||||
return make_tl_object<td_api::richTextReference>(texts[0].get_rich_text_object(context), anchor.str(),
|
}
|
||||||
content);
|
auto it = context->anchors_.find(anchor);
|
||||||
|
if (it != context->anchors_.end()) {
|
||||||
|
if (it->second == nullptr) {
|
||||||
|
return make_tl_object<td_api::richTextAnchorLink>(texts[0].get_rich_text_object(context),
|
||||||
|
anchor.str(), content);
|
||||||
|
} else {
|
||||||
|
return make_tl_object<td_api::richTextReference>(texts[0].get_rich_text_object(context), anchor.str(),
|
||||||
|
content);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user