当前位置: 首页>>代码示例>>PHP>>正文


PHP HTMLPurifier_URISchemeRegistry类代码示例

本文整理汇总了PHP中HTMLPurifier_URISchemeRegistry的典型用法代码示例。如果您正苦于以下问题:PHP HTMLPurifier_URISchemeRegistry类的具体用法?PHP HTMLPurifier_URISchemeRegistry怎么用?PHP HTMLPurifier_URISchemeRegistry使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了HTMLPurifier_URISchemeRegistry类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: test

 function test()
 {
     generate_mock_once('HTMLPurifier_URIScheme');
     $config = HTMLPurifier_Config::create(array('URI.AllowedSchemes' => 'http, telnet', 'URI.OverrideAllowedSchemes' => true));
     $context = new HTMLPurifier_Context();
     $registry = new HTMLPurifier_URISchemeRegistry();
     $this->assertIsA($registry->getScheme('http', $config, $context), 'HTMLPurifier_URIScheme_http');
     $scheme_http = new HTMLPurifier_URISchemeMock();
     $scheme_telnet = new HTMLPurifier_URISchemeMock();
     $scheme_foobar = new HTMLPurifier_URISchemeMock();
     // register a new scheme
     $registry->register('telnet', $scheme_telnet);
     $this->assertIdentical($registry->getScheme('telnet', $config, $context), $scheme_telnet);
     // overload a scheme, this is FINAL (forget about defaults)
     $registry->register('http', $scheme_http);
     $this->assertIdentical($registry->getScheme('http', $config, $context), $scheme_http);
     // when we register a scheme, it's automatically allowed
     $registry->register('foobar', $scheme_foobar);
     $this->assertIdentical($registry->getScheme('foobar', $config, $context), $scheme_foobar);
     // now, test when overriding is not allowed
     $config = HTMLPurifier_Config::create(array('URI.AllowedSchemes' => 'http, telnet', 'URI.OverrideAllowedSchemes' => false));
     $this->assertNull($registry->getScheme('foobar', $config, $context));
     // scheme not allowed and never registered
     $this->assertNull($registry->getScheme('ftp', $config, $context));
 }
开发者ID:artbypravesh,项目名称:morningpages,代码行数:25,代码来源:URISchemeRegistryTest.php

示例2: getSchemeObj

 /**
  * Retrieves a scheme object corresponding to the URI's scheme/default
  * @param $config Instance of HTMLPurifier_Config
  * @param $context Instance of HTMLPurifier_Context
  * @return Scheme object appropriate for validating this URI
  */
 function getSchemeObj($config, &$context)
 {
     $registry =& HTMLPurifier_URISchemeRegistry::instance();
     if ($this->scheme !== null) {
         $scheme_obj = $registry->getScheme($this->scheme, $config, $context);
         if (!$scheme_obj) {
             return false;
         }
         // invalid scheme, clean it out
     } else {
         // no scheme: retrieve the default one
         $def = $config->getDefinition('URI');
         $scheme_obj = $registry->getScheme($def->defaultScheme, $config, $context);
         if (!$scheme_obj) {
             // something funky happened to the default scheme object
             trigger_error('Default scheme object "' . $def->defaultScheme . '" was not readable', E_USER_WARNING);
             return false;
         }
     }
     return $scheme_obj;
 }
开发者ID:fferriere,项目名称:web,代码行数:27,代码来源:URI.php

示例3: filter

 public function filter(&$uri, $config, $context)
 {
     if ($context->get('EmbeddedURI', true) && !$this->doEmbed) {
         return true;
     }
     $scheme_obj = $uri->getSchemeObj($config, $context);
     if (!$scheme_obj) {
         return true;
     }
     // ignore unknown schemes, maybe another postfilter did it
     if (!$scheme_obj->browsable) {
         return true;
     }
     // ignore non-browseable schemes
     // don't redirect if target host is our host
     if ($uri->isLocal($config, $context)) {
         $uri_definition = $config->getDefinition('URI');
         // but do redirect if we're currently on a secure scheme,
         // and the target scheme is insecure
         $current_scheme_obj = HTMLPurifier_URISchemeRegistry::instance()->getScheme($uri_definition->defaultScheme, $config, $context);
         if ($scheme_obj->secure || !$current_scheme_obj->secure) {
             return true;
         }
         // target scheme was not secure, but we were secure
     }
     $this->makeReplace($uri, $config, $context);
     $this->replace = array_map('rawurlencode', $this->replace);
     $new_uri = strtr($this->target, $this->replace);
     $new_uri = $this->parser->parse($new_uri);
     // don't redirect if the target host is the same as the
     // starting host
     if ($uri->host === $new_uri->host) {
         return true;
     }
     $uri = $new_uri;
     // overwrite
     return true;
 }
开发者ID:TheoJD,项目名称:portail,代码行数:38,代码来源:Munge.php

示例4: getDefaultScheme

 public function getDefaultScheme($config, $context)
 {
     return HTMLPurifier_URISchemeRegistry::instance()->getScheme($this->defaultScheme, $config, $context);
 }
开发者ID:dingdong2310,项目名称:g5_theme,代码行数:4,代码来源:HTMLPurifier.standalone.php

示例5: __construct

 function __construct()
 {
     global $sugar_config;
     $config = HTMLPurifier_Config::createDefault();
     if (!is_dir(sugar_cached("htmlclean"))) {
         create_cache_directory("htmlclean/");
     }
     $config->set('HTML.Doctype', 'XHTML 1.0 Transitional');
     $config->set('Core.Encoding', 'UTF-8');
     $hidden_tags = ['script' => true, 'style' => true, 'title' => true, 'head' => true];
     $config->set('Core.HiddenElements', $hidden_tags);
     $config->set('Cache.SerializerPath', sugar_cached("htmlclean"));
     $config->set('URI.Base', $sugar_config['site_url']);
     $config->set('CSS.Proprietary', true);
     $config->set('HTML.TidyLevel', 'light');
     $config->set('HTML.ForbiddenElements', ['body' => true, 'html' => true]);
     $config->set('AutoFormat.RemoveEmpty', false);
     $config->set('Cache.SerializerPermissions', 0775);
     // for style
     //$config->set('Filter.ExtractStyleBlocks', true);
     $config->set('Filter.ExtractStyleBlocks.TidyImpl', false);
     // can't use csstidy, GPL
     if (!empty($GLOBALS['sugar_config']['html_allow_objects'])) {
         // for object
         $config->set('HTML.SafeObject', true);
         // for embed
         $config->set('HTML.SafeEmbed', true);
     }
     $config->set('Output.FlashCompat', true);
     // for iframe and xmp
     $config->set('Filter.Custom', [new HTMLPurifier_Filter_Xmp()]);
     // for link
     $config->set('HTML.DefinitionID', 'Sugar HTML Def');
     $config->set('HTML.DefinitionRev', 2);
     $config->set('Cache.SerializerPath', sugar_cached('htmlclean/'));
     // IDs are namespaced
     $config->set('Attr.EnableID', true);
     $config->set('Attr.IDPrefix', 'sugar_text_');
     if ($def = $config->maybeGetRawHTMLDefinition()) {
         $form = $def->addElement('link', 'Flow', 'Empty', 'Core', ['href*' => 'URI', 'rel' => 'Enum#stylesheet', 'type' => 'Enum#text/css']);
         $iframe = $def->addElement('iframe', 'Flow', 'Optional: #PCDATA | Flow | Block', 'Core', ['src*' => 'URI', 'frameborder' => 'Enum#0,1', 'marginwidth' => 'Pixels', 'marginheight' => 'Pixels', 'scrolling' => 'Enum#|yes,no,auto', 'align' => 'Enum#top,middle,bottom,left,right,center', 'height' => 'Length', 'width' => 'Length']);
         $iframe->excludes = ['iframe'];
     }
     $uri = $config->getDefinition('URI');
     $uri->addFilter(new SugarURIFilter(), $config);
     HTMLPurifier_URISchemeRegistry::instance()->register('cid', new HTMLPurifier_URIScheme_cid());
     $this->purifier = new HTMLPurifier($config);
 }
开发者ID:butschster,项目名称:sugarcrm_dev,代码行数:48,代码来源:clean.php

示例6: tearDownSchemeRegistryMock

 protected function tearDownSchemeRegistryMock()
 {
     HTMLPurifier_URISchemeRegistry::instance($this->oldRegistry);
 }
开发者ID:patdunlavey,项目名称:Williamstown-Beat,代码行数:4,代码来源:URITest.php


注:本文中的HTMLPurifier_URISchemeRegistry类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。