ezyang / htmlpurifier

Standards compliant HTML filter written in PHP
http://htmlpurifier.org
GNU Lesser General Public License v2.1
3.07k stars 327 forks source link

Dont work Telegram, Viber href=tg:// #315

Open mazai opened 2 years ago

mazai commented 2 years ago

Send: <a href="http://www.example.com/">inline URL</a> <a href="tg://user?id=123456789">inline mention of a user</a> <a href="tg://msg?text=text&to=+79851112233">msg with text</a> <a href="callto:79851112233">call</a> <a href="tel:+496170961709" >call</a> Result: <a href="http://www.example.com/">inline URL</a> <a>inline mention of a user</a> <a>msg with text</a> <a>call</a> <a href="tel:+496170961709">call</a>

Help!
bytestream commented 2 years ago

You would need to register a custom URI scheme http://htmlpurifier.org/docs/enduser-uri-filter.html

pyres01 commented 2 years ago

邮件已收到,谢谢!

mazai commented 2 years ago

More valid links for test:

Telegram:

<a href="tg://resolve?domain=username">Send Personal Message</a>
<a href="tg://join?invite=invite_link">Join Group</a>
<a href="tg://msg?text=Text">Telegram</a>
<a href="tg://msg?text=Text&to=0001112233">Telegram</a>
<a href="tg://addstickers?set=NAME">Stickrs</a>

Viber:

<a href="viber://add?number=12345678">Viber</a>
<a href="viber://chat?number=12345678">Viber</a>
<a href="viber://pa?chatURI=[public account URI]&text=[message text]">Viber</a>

WhatsApp:

<a href="whatsapp://send?text=Text" data-action="share/whatsapp/share">WhatsApp</a>
<a href="whatsapp://send?text=Text"&abid=ABID" data-action="share/whatsapp/share">WhatsApp</a>
mazai commented 2 years ago

You would need to register a custom URI scheme http://htmlpurifier.org/docs/enduser-uri-filter.html

Tnx! If they exist and they are popular, maybe it makes sense to add them to the scheme?

        $config->set(
            'URI.AllowedSchemes',
            array(
                'http' => true,
                'https' => true,
                'mailto' => true,
                'ftp' => true,
                'ftps' => true,
                'nntp' => true,
                'news' => true,
                'tg' => true,
                'tel' => true,
                'callto' => true,
                'data' => true,
                'viber' => true,
                'whatsapp'=>true
            )
        );