Merge pull request #9963 from mexon/mat/support-cid-scheme

Support cid URLs as used in mailstream plugin
This commit is contained in:
Hypolite Petovan 2021-02-27 12:11:15 -05:00 committed by GitHub
commit a6423031eb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 40 additions and 0 deletions

View file

@ -29,6 +29,7 @@ use Friendica\Content\Item;
use Friendica\Content\OEmbed; use Friendica\Content\OEmbed;
use Friendica\Content\PageInfo; use Friendica\Content\PageInfo;
use Friendica\Content\Smilies; use Friendica\Content\Smilies;
use Friendica\Content\Text\HTMLPurifier_URIScheme_cid;
use Friendica\Core\Hook; use Friendica\Core\Hook;
use Friendica\Core\Logger; use Friendica\Core\Logger;
use Friendica\Core\Protocol; use Friendica\Core\Protocol;
@ -1876,6 +1877,8 @@ class BBCode
$text $text
); );
\HTMLPurifier_URISchemeRegistry::instance()->register('cid', new HTMLPurifier_URIScheme_cid());
$config = \HTMLPurifier_HTML5Config::createDefault(); $config = \HTMLPurifier_HTML5Config::createDefault();
$config->set('HTML.Doctype', 'HTML5'); $config->set('HTML.Doctype', 'HTML5');
$config->set('HTML.SafeIframe', true); $config->set('HTML.SafeIframe', true);

View file

@ -0,0 +1,37 @@
<?php
namespace Friendica\Content\Text;
use \HTMLPurifier_URIScheme;
/**
* Validates content-id ("cid") as used in multi-part MIME messages, as defined by RFC 2392
*/
class HTMLPurifier_URIScheme_cid extends HTMLPurifier_URIScheme
{
/**
* @type bool
*/
public $browsable = true;
/**
* @type bool
*/
public $may_omit_host = true;
/**
* @param HTMLPurifier_URI $uri
* @param HTMLPurifier_Config $config
* @param HTMLPurifier_Context $context
* @return bool
*/
public function doValidate(&$uri, $config, $context)
{
$uri->userinfo = null;
$uri->host = null;
$uri->port = null;
$uri->query = null;
// typecode check needed on path
return true;
}
}