當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Sanitizer::fixDeprecatedAttributes方法代碼示例

本文整理匯總了PHP中Sanitizer::fixDeprecatedAttributes方法的典型用法代碼示例。如果您正苦於以下問題:PHP Sanitizer::fixDeprecatedAttributes方法的具體用法?PHP Sanitizer::fixDeprecatedAttributes怎麽用?PHP Sanitizer::fixDeprecatedAttributes使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Sanitizer的用法示例。


在下文中一共展示了Sanitizer::fixDeprecatedAttributes方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: fixTagAttributes

 /**
  * Take a tag soup fragment listing an HTML element's attributes
  * and normalize it to well-formed XML, discarding unwanted attributes.
  * Output is safe for further wikitext processing, with escaping of
  * values that could trigger problems.
  *
  * - Normalizes attribute names to lowercase
  * - Discards attributes not on a whitelist for the given element
  * - Turns broken or invalid entities into plaintext
  * - Double-quotes all attribute values
  * - Attributes without values are given the name as attribute
  * - Double attributes are discarded
  * - Unsafe style attributes are discarded
  * - Prepends space if there are attributes.
  *
  * @param $text String
  * @param $element String
  * @return String
  */
 static function fixTagAttributes($text, $element)
 {
     if (trim($text) == '') {
         return '';
     }
     $decoded = Sanitizer::decodeTagAttributes($text);
     $decoded = Sanitizer::fixDeprecatedAttributes($decoded, $element);
     $stripped = Sanitizer::validateTagAttributes($decoded, $element);
     $attribs = array();
     foreach ($stripped as $attribute => $value) {
         $encAttribute = htmlspecialchars($attribute);
         $encValue = Sanitizer::safeEncodeAttribute($value);
         $attribs[] = "{$encAttribute}=\"{$encValue}\"";
     }
     return count($attribs) ? ' ' . implode(' ', $attribs) : '';
 }
開發者ID:slackfaith,項目名稱:deadbrain_site,代碼行數:35,代碼來源:Sanitizer.php

示例2: fixTagAttributes

 /**
  * Take a tag soup fragment listing an HTML element's attributes
  * and normalize it to well-formed XML, discarding unwanted attributes.
  * Output is safe for further wikitext processing, with escaping of
  * values that could trigger problems.
  *
  * - Normalizes attribute names to lowercase
  * - Discards attributes not on a whitelist for the given element
  * - Turns broken or invalid entities into plaintext
  * - Double-quotes all attribute values
  * - Attributes without values are given the name as attribute
  * - Double attributes are discarded
  * - Unsafe style attributes are discarded
  * - Prepends space if there are attributes.
  *
  * @param $text String
  * @param $element String
  * @return String
  */
 static function fixTagAttributes($text, $element)
 {
     if (trim($text) == '') {
         return '';
     }
     $decoded = Sanitizer::decodeTagAttributes($text);
     $decoded = Sanitizer::fixDeprecatedAttributes($decoded, $element);
     $stripped = Sanitizer::validateTagAttributes($decoded, $element);
     $attribs = array();
     foreach ($stripped as $attribute => $value) {
         $encAttribute = htmlspecialchars($attribute);
         $encValue = Sanitizer::safeEncodeAttribute($value);
         # RTE (Rich Text Editor) - begin
         # @author: Inez Korczyński, macbre
         global $wgRTEParserEnabled;
         if (!empty($wgRTEParserEnabled) && $encAttribute == 'style') {
             // BugId:2462 - remove apostrophes from style attribute
             $encValue = str_replace(''', '', $encValue);
             $attribs[] = "data-rte-style=\"{$encValue}\"";
         }
         # RTE - end
         $attribs[] = "{$encAttribute}=\"{$encValue}\"";
     }
     # RTE (Rich Text Editor) - begin
     # @author: Inez Korczyński
     global $wgRTEParserEnabled;
     if (!empty($wgRTEParserEnabled)) {
         if (strpos($text, "") !== false) {
             RTE::$edgeCases[] = 'COMPLEX.08';
         }
         $attribs[] = RTEParser::encodeAttributesStr($text);
     }
     # RTE - end
     return count($attribs) ? ' ' . implode(' ', $attribs) : '';
 }
開發者ID:Tjorriemorrie,項目名稱:app,代碼行數:54,代碼來源:Sanitizer.php


注:本文中的Sanitizer::fixDeprecatedAttributes方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。