You are here

function mimemail_isshellsafe in Mime Mail 7

Same name and namespace in other branches
  1. 6 mimemail.module \mimemail_isshellsafe()

Disallows potentially unsafe shell characters.

Parameters

string $string: The string to be validated.

Return value

bool True if the string is shell-safe.

1 call to mimemail_isshellsafe()
mimemail_mailengine in ./mimemail.module
Implements hook_mailengine().

File

./mimemail.module, line 436
Component module for sending Mime-encoded emails.

Code

function mimemail_isshellsafe($string) {
  if (escapeshellcmd($string) !== $string || !in_array(escapeshellarg($string), array(
    "'{$string}'",
    "\"{$string}\"",
  ))) {
    return FALSE;
  }
  if (preg_match('/[^a-zA-Z0-9@_\\-.]/', $string) !== 0) {
    return FALSE;
  }
  return TRUE;
}