00001 <?php
00002
00010 class HTMLPurifier_AttrDef_HTML_Nmtokens extends HTMLPurifier_AttrDef
00011 {
00012
00013 public function validate($string, $config, $context) {
00014
00015 $string = trim($string);
00016
00017
00018 if (!$string) return false;
00019
00020
00021
00022
00023
00024
00025
00026
00027 $matches = array();
00028 $pattern = '/(?:(?<=\s)|\A)'.
00029 '((?:--|-?[A-Za-z_])[A-Za-z_\-0-9]*)'.
00030 '(?:(?=\s)|\z)/';
00031 preg_match_all($pattern, $string, $matches);
00032
00033 if (empty($matches[1])) return false;
00034
00035
00036 $new_string = '';
00037 foreach ($matches[1] as $token) {
00038 $new_string .= $token . ' ';
00039 }
00040 $new_string = rtrim($new_string);
00041
00042 return $new_string;
00043
00044 }
00045
00046 }
00047