You are here

function _phpmailer_smtp_stack in PHPMailer SMTP 2.x

Same name and namespace in other branches
  1. 8 phpmailer_smtp.module \_phpmailer_smtp_stack()

Implements a FIFO stack to store extracted quoted strings.

1 string reference to '_phpmailer_smtp_stack'
phpmailer_smtp_parse_address in ./phpmailer_smtp.module
Extract address and optional display name of an e-mail address.

File

./phpmailer_smtp.module, line 85
Uses the PHPMailer library to send emails via SMTP.

Code

function _phpmailer_smtp_stack($matches = NULL) {
  $string = $matches[0];
  static $stack = [];
  if ($string == "\1") {

    // Unescape quoted characters (3.2.4) to prevent double escaping.
    return str_replace([
      '\\"',
      '\\\\',
    ], [
      '"',
      '\\',
    ], array_shift($stack));
  }

  // Remove surrounding quotes and push on stack.
  array_push($stack, substr($string, 1, -1));

  // Return placeholder substitution. 0x01 may never appear outside a quoted
  // string (3.2.3).
  return "\1";
}