Remove <a target=...>

This commit is contained in:
blankie 2023-12-06 08:35:51 +11:00
parent 695bad8ed6
commit 1f5e329385
Signed by: blankie
GPG Key ID: CC15FC822C7F61F5
1 changed files with 7 additions and 1 deletions

View File

@ -266,6 +266,12 @@ static std::regex mention_class_re("\\bmention\\b");
static inline void preprocess_link(const httplib::Request& req, const std::string& domain_name, lxb_dom_element_t* element) {
using namespace std::string_literals;
// Remove target=...
lxb_status_t status = lxb_dom_element_remove_attribute(element, reinterpret_cast<const lxb_char_t*>("target"), 6);
if (status != LXB_STATUS_OK) {
throw LXB::Exception(status);
}
size_t href_c_len;
const lxb_char_t* href_c = lxb_dom_element_get_attribute(element, reinterpret_cast<const lxb_char_t*>("href"), 4, &href_c_len);
if (!href_c) {
@ -304,7 +310,7 @@ static inline void preprocess_link(const httplib::Request& req, const std::strin
if (should_fix_link(element, cls)) {
// Set the content of each <a> to its href
lxb_status_t status = lxb_dom_node_text_content_set(lxb_dom_interface_node(element), reinterpret_cast<const lxb_char_t*>(href.data()), href.size());
status = lxb_dom_node_text_content_set(lxb_dom_interface_node(element), reinterpret_cast<const lxb_char_t*>(href.data()), href.size());
if (status != LXB_STATUS_OK) {
throw LXB::Exception(status);
}