/** * Reads in a tweet to be parsed and hit highlighted. * * We take this opportunity to ensure that we escape user input. * * @see htmlspecialchars() * * @param string $tweet The tweet to be hit highlighted. * @param bool $escape Whether to escape the tweet (default: true). * @param bool $full_encode Whether to encode all special characters. */ public function __construct($tweet, $escape = true, $full_encode = false) { if ($escape) { if ($full_encode) { parent::__construct(htmlentities($tweet, ENT_QUOTES, 'UTF-8', false)); } else { parent::__construct(htmlspecialchars($tweet, ENT_QUOTES, 'UTF-8', false)); } } else { parent::__construct($tweet); } }
/** * Reads in a tweet to be parsed and validates it. * * @param string $tweet The tweet to validate. */ public function __construct($tweet) { parent::__construct($tweet); }
$tmp['validate_url_host'] = '(?:' . $tmp['validate_url_ip'] . '|' . $tmp['validate_url_domain'] . ')'; #/iox # Unencoded internationalized domains - this doesn't check for invalid UTF-8 sequences $tmp['validate_url_unicode_subdomain_segment'] = '(?:(?:[a-z0-9]|[^\\x00-\\x7f])(?:(?:[a-z0-9_\\-]|[^\\x00-\\x7f])*(?:[a-z0-9]|[^\\x00-\\x7f]))?)'; #/ix $tmp['validate_url_unicode_domain_segment'] = '(?:(?:[a-z0-9]|[^\\x00-\\x7f])(?:(?:[a-z0-9\\-]|[^\\x00-\\x7f])*(?:[a-z0-9]|[^\\x00-\\x7f]))?)'; #/ix $tmp['validate_url_unicode_domain_tld'] = '(?:(?:[a-z]|[^\\x00-\\x7f])(?:(?:[a-z0-9\\-]|[^\\x00-\\x7f])*(?:[a-z0-9]|[^\\x00-\\x7f]))?)'; #/ix $tmp['validate_url_unicode_domain'] = '(?:(?:' . $tmp['validate_url_unicode_subdomain_segment'] . '\\.)*(?:' . $tmp['validate_url_unicode_domain_segment'] . '\\.)' . $tmp['validate_url_unicode_domain_tld'] . ')'; #/iox $tmp['validate_url_unicode_host'] = '(?:' . $tmp['validate_url_ip'] . '|' . $tmp['validate_url_unicode_domain'] . ')'; #/iox $tmp['validate_url_port'] = '[0-9]{1,5}'; $re['validate_url_unicode_authority'] = '/' . '(?:(' . $tmp['validate_url_userinfo'] . ')@)?' . '(' . $tmp['validate_url_unicode_host'] . ')' . '(?::(' . $tmp['validate_url_port'] . '))?' . '/iux'; $re['validate_url_authority'] = '/' . '(?:(' . $tmp['validate_url_userinfo'] . ')@)?' . '(' . $tmp['validate_url_host'] . ')' . '(?::(' . $tmp['validate_url_port'] . '))?' . '/ix'; $re['validate_url_scheme'] = '/(?:[a-z][a-z0-9+\\-.]*)/i'; $re['validate_url_path'] = '/(\\/' . $tmp['validate_url_pchar'] . '*)*/i'; $re['validate_url_query'] = '/(' . $tmp['validate_url_pchar'] . '|\\/|\\?)*/i'; $re['validate_url_fragment'] = '/(' . $tmp['validate_url_pchar'] . '|\\/|\\?)*/i'; # Modified version of RFC 3986 Appendix B $re['validate_url_unencoded'] = '/^' . '(?:' . '([^:\\/?#]+):\\/\\/' . ')?' . '([^\\/?#]*)' . '([^?#]*)' . '(?:' . '\\?([^#]*)' . ')?' . '(?:' . '\\#(.*)' . ')?$/iux'; $re['invalid_characters'] = '/[' . $tmp['invalid_characters'] . ']/u'; # Flag that initialization is complete: $initialized = true; } } # Cause regular expressions to be initialized as soon as this file is loaded: TwitterText_Regex::__static(); ################################################################################ # vim:et:ft=php:nowrap:sts=2:sw=2:ts=2