Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.
   1  <?php
   2  
   3  /**

   4   * Validates the value for the CSS property text-decoration

   5   * @note This class could be generalized into a version that acts sort of

   6   *       like Enum except you can compound the allowed values.

   7   */
   8  class HTMLPurifier_AttrDef_CSS_TextDecoration extends HTMLPurifier_AttrDef
   9  {
  10  
  11      /**

  12       * @param string $string

  13       * @param HTMLPurifier_Config $config

  14       * @param HTMLPurifier_Context $context

  15       * @return bool|string

  16       */
  17      public function validate($string, $config, $context)
  18      {
  19          static $allowed_values = array(
  20              'line-through' => true,
  21              'overline' => true,
  22              'underline' => true,
  23          );
  24  
  25          $string = strtolower($this->parseCDATA($string));
  26  
  27          if ($string === 'none') {
  28              return $string;
  29          }
  30  
  31          $parts = explode(' ', $string);
  32          $final = '';
  33          foreach ($parts as $part) {
  34              if (isset($allowed_values[$part])) {
  35                  $final .= $part . ' ';
  36              }
  37          }
  38          $final = rtrim($final);
  39          if ($final === '') {
  40              return false;
  41          }
  42          return $final;
  43      }
  44  }
  45  
  46  // vim: et sw=4 sts=4