You are here

function CoderSecurityTest::testSecurityFormError in Coder 6.2

File

tests/coder_security.test, line 110

Class

CoderSecurityTest

Code

function testSecurityFormError() {
  $this
    ->assertCoderPass('  form_error("name", t("Here is some safe_data"));');
  $this
    ->assertCoderPass('  form_error($name, t("Here is some safe_data"));');
  $this
    ->assertCoderPass('  form_error($name, t("Here is some @safe_data", array("@safe_data" => $tainted_data));');
  $this
    ->assertCoderPass('  form_error($name, t("Here is some %safe_data", array("%safe_data" => $tainted_data));');
  $this
    ->assertCoderPass('  form_error($name, t("Here is some @safe_data", $safe_data_array));');
  $this
    ->assertCoderPass('  form_error($name, check_plain($tainted_data));');
  $this
    ->assertCoderPass('  form_error($name, filter_xss_admin($tainted_data));');
  $this
    ->assertCoderPass('  form_error($name, format_plural($tainted_count, "1 item", "@count items"));');
  $this
    ->assertCoderPass('  form_error($name, check_markup($tainted_data));');
  $this
    ->assertCoderPass("  function abc() {\n \$tainted_data = check_plain('mystring');\n  form_error(\$name, \$tainted_data);\n}");
  $this
    ->assertCoderFail("  function abc() {\n form_error(\$name, \$tainted_data);\n}");
  $this
    ->assertCoderFail('  form_error($name, t($tainted_data));');
  $this
    ->assertCoderFail('  form_error($name, "Here is some ". $tainted_data);');
  $this
    ->assertCoderFail('  form_error($name, "Here is some $tainted_data");');
  $this
    ->assertCoderFail('  form_error($name, t("Here is some ". $tainted_data));');
  $this
    ->assertCoderFail('  form_error($name, t("Here is some !tainted_data", array("!tainted_data" => $tainted_data));');
}