You are here

function mimemail_isshellsafe in Mime Mail 6

Same name and namespace in other branches
  1. 7 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
The default mailengine.

File

./mimemail.module, line 456
Component module for sending MIME-encoded e-mails.

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;
}