You are here

interface SpamspanInterface in SpamSpan filter 8.2

Same name and namespace in other branches
  1. 8 src/SpamspanInterface.php \Drupal\spamspan\SpamspanInterface

Spamspan interface.

Hierarchy

Expanded class hierarchy of SpamspanInterface

All classes that implement SpamspanInterface

1 file declares its use of SpamspanInterface
FilterSpamspan.php in src/Plugin/Filter/FilterSpamspan.php

File

src/SpamspanInterface.php, line 8

Namespace

Drupal\spamspan
View source
interface SpamspanInterface {

  /**
   * Special characters in the local part.
   */
  const PATTERN_SPECIAL = '\\-\\.\\~\'\\!\\#$\\%\\&\\+\\/\\*\\=\\?\\^\\_\\`\\{\\|\\}\\+^@';

  /**
   * Set up a regex constant to split an email into name and domain parts.
   *
   * The following pattern is not perfect (who is?), but is intended to
   * intercept things which look like email addresses.  It is not intended to
   * determine if an address is valid.  It will not intercept addresses with
   * quoted local parts.
   */
  const PATTERN_MAIN = '([' . self::PATTERN_SPECIAL . '\\w]+)@' . '((?:' . '[-\\w]+\\.' . ')+' . '[A-Z]{2,63})';
  const PATTERN_EMAIL_BARE = '!' . self::PATTERN_MAIN . '!ix';

  /**
   * For cases when spamspan_use_form is checked.
   *
   * Example: user@example.museum[mycontactform|Contact me using this form].
   */
  const PATTERN_EMAIL_WITH_OPTIONS = '!' . self::PATTERN_MAIN . '\\[(.*?)\\]!ix';

  /**
   * Regex for mailto URLs.
   *
   * See http://www.faqs.org/rfcs/rfc2368.html.
   * This captures the whole mailto URL into the second group,
   * the name into the third group and the domain into the fourth.
   * Attributes before href go into first group and the ones after into fifth.
   * The tag contents go into the sixth.
   */
  const PATTERN_MAILTO = '!<a\\s+' . "((?:(?:[\\w|-]+\\s*=\\s*)(?:\\w+|\"[^\"]*\"|'[^']*')\\s*)*?)" . "href\\s*=\\s*(['\"])\\s*(mailto:" . self::PATTERN_MAIN . "(?:\\?[A-Za-z0-9_= %\\.\\-\\~\\_\\&;\\!\\*\\(\\)\\'#&]*)?\\s*)" . '\\2' . "((?:(?:\\s+[\\w|-]+\\s*=\\s*)(?:\\w+|\"[^\"]*\"|'[^']*'))*?)" . '>' . '(.*?)' . '</a>!ixs';

  /**
   * Obfuscation based on PATTERN_EMAIL_BARE.
   *
   * @param string $text
   *   Text obfuscate.
   * @param bool $altered
   *   Sets this to true if any obfuscation occurred.
   *
   * @return string
   *   The obfuscated text.
   */
  public function replaceBareEmailAddresses($text, &$altered = NULL);

  /**
   * Obfuscation based on PATTERN_EMAIL_WITH_OPTIONS.
   *
   * @param string $text
   *   Text obfuscate.
   * @param bool $altered
   *   Sets this to true if any obfuscation occurred.
   *
   * @return string
   *   The obfuscated text.
   */
  public function replaceEmailAddressesWithOptions($text, &$altered = NULL);

  /**
   * Obfuscation based on PATTERN_MAILTO.
   *
   * @param string $text
   *   Text obfuscate.
   * @param bool $altered
   *   Sets this to true if any obfuscation occurred.
   *
   * @return string
   *   The obfuscated text.
   */
  public function replaceMailtoLinks($text, &$altered = NULL);

}

Members

Namesort descending Modifiers Type Description Overrides
SpamspanInterface::PATTERN_EMAIL_BARE constant
SpamspanInterface::PATTERN_EMAIL_WITH_OPTIONS constant For cases when spamspan_use_form is checked.
SpamspanInterface::PATTERN_MAILTO constant Regex for mailto URLs.
SpamspanInterface::PATTERN_MAIN constant Set up a regex constant to split an email into name and domain parts.
SpamspanInterface::PATTERN_SPECIAL constant Special characters in the local part.
SpamspanInterface::replaceBareEmailAddresses public function Obfuscation based on PATTERN_EMAIL_BARE.
SpamspanInterface::replaceEmailAddressesWithOptions public function Obfuscation based on PATTERN_EMAIL_WITH_OPTIONS.
SpamspanInterface::replaceMailtoLinks public function Obfuscation based on PATTERN_MAILTO.