Bug fixes and code beautification

* Fixed password masking when the message has more than one password
* Reading php://input in a separate line, for later debugging purposes
This commit is contained in:
Polonkai Gergely 2012-02-28 13:00:45 +01:00
parent 31c6abc039
commit 45f439ba68
2 changed files with 6 additions and 2 deletions

View File

@ -47,7 +47,8 @@ class jsonRPCServer {
} }
// reads the input data // reads the input data
$request = json_decode(file_get_contents('php://input'),true); $request_string = file_get_contents('php://input');
$request = json_decode($request_string,true);
// executes the task on local object // executes the task on local object
try { try {

View File

@ -6,6 +6,7 @@ class smsSender
protected $sessionId = null; protected $sessionId = null;
protected $dbBackend; protected $dbBackend;
protected $smsBackend; protected $smsBackend;
const password_mask = '<masked password>';
public function __construct($dbBackend, $smsBackend, $sessionId) public function __construct($dbBackend, $smsBackend, $sessionId)
{ {
@ -66,9 +67,11 @@ class smsSender
{ {
$msg = $message; $msg = $message;
$mod = 0;
foreach ($passwordLocations as $loc) foreach ($passwordLocations as $loc)
{ {
$msg = substr_replace($msg, '<masked password>', $loc[0], $loc[1]); $msg = substr_replace($msg, self::password_mask, $loc[0] + $mod, $loc[1]);
$mod += (strlen(self::password_mask) - $loc[1]);
} }
return $msg; return $msg;