Latte filter – noescape in href
- pn-pm
- Member | 20
Im trying to make a filter email_link to create mailto link, obfuscated against spammers, by using html entities and prepending also the ‘mailto:’ protocol prefix (will use for own validated addresses)
It is not working in the href attribute, only if i add modifiers
**|nocheck|noescape **
Is there a way to modify the filter, so i dont have to use the modifiers
inline
Maybe some special contentType, or way to apply modifiers to FilterInfo
object ?
// WORKS
<a href="{$email|email_link|nocheck|noescape}">{$email|email_text}</a> ...
// DOESNT WORK (href attribute is empty)
<a href="{$email|email_link}">{$email|email_text}</a> ...
// Example of antispambot resulting address: email@adresa.xy
function filter_email_link(FilterInfo $info, $str){
// $info->contentType = \Latte\ContentType::Text; ???
return 'mailto' . ':' . antispambot($str); // 'mailto' => encoded mailto:
}
function filter_email_text(FilterInfo $info, $str){
// html contentType allow encoded entities, but not in attribute
$info->contentType = \Latte\ContentType::Html;
return 'mailto' . ':' . antispambot($str);
}
Problem is, the content-aware filter rejects the encoded mailto link, if used in href
Last edited by pn-pm (2023-09-06 12:52)