orig_ini_encoding_val = ini_get('mbstring.encoding_translation'); //set http translation on ini_set('mbstring.encoding_translation',1); } public function tearDown() { //set back value of ini setting ini_set('mbstring.encoding_translation',$this->orig_ini_encoding_val); unset($this->orig_ini_encoding_val); } public function testEncodedKeyCleaning() { //continue this test only if encoding_translation is turned on. if(ini_get('mbstring.encoding_translation')==='1'){ //inject bad string into request $key = "'you'shall'not'pass!"; $val = ' must.. not.. die..'; $_REQUEST[$key] = $val; //assert the key is in the request object $this->assertsame($_REQUEST[$key], $val, 'request key was not set, rest of test is invalid'); //clean the string, it should fail but since encoding translation is on, it should only remove the //key from request object securexsskey($key,false); //assert the key is no longer in request $this->assertNotContains($key,$_REQUEST,'Key should not hav passed xss security check, but still exists in request, this is wrong.'); }else{ //encoding_translation is turned off, this test will not work, so let's skip it $this->markTestSkipped('mbstring.encoding_translation is turned off, mark as skipped for now.'); } } }