Hi,
@benjaminsmith,
I made the change to line 587, but still no luck.
Here's diff of the change I made and tested:
Code: Select all
# diff xicore.inc.php.orig xicore.inc.php
587c587
< $msg = substr($email['body'], 0, $msg_end);
---
> $msg = preg_replace("/[\\r\\n]+/", "\n", substr($email['body'], 0, $msg_end));
Here's sample result from cleaner.log:
Code: Select all
Running callbacks:
Error - Could not find a host object in the hash provided
Processed 1 incoming emails
----------------------------------
Given that error message, I'm not sure I'm getting to line 587.
Seems to fail the check starting at line 562:
Code: Select all
// Verify that at least a hostname is present
if (empty($obj->host)) {
echo "Error - Could not find a host object in the hash provided\n";
$error = true;
}
Something interesting, of note...
Previously, I'd added a line for debugging, around 563, to echo the email body:
That was where I was seeing the ^M in the hash, in the cleaner.log:
Code: Select all
-----^M
^M
To reply, keep the following data in your response email.^M
^M
##YTk2M2IzNmQ5NGRjMDU3YW1GVm5vNlNmdURYMzVHU0UxWHd1R0RweVpQdUJNTXliTy9EYThPe=^M
XVJQ0R4djRkVWxmbW5TLzY0ZSt0THppL1FuK21EOGVEZVF6eG40emJEQzZ5WmpRPT0=3D##^M
^M
Error - Could not find a host object in the hash provided
Processed 1 incoming emails
However, I've now removed the "echo email body" line replaced it with the following, starting at 561:
Code: Select all
$hash = trim(str_replace(array('> ', '>', '=', "\n", "\t", "\r"), '', substr($email['body'], $start + 2, $end - $start - 2)));
$obj = json_decode(decrypt_data($hash));
echo "hash: " . $hash . "\n";
echo "\$obj = json_decode(decrypt_data($hash))\n";
$error = json_last_error();
echo "json_last_error: " . $error . "\n";
var_dump($obj);
Following are sample results from cleaner.log, after adding those lines:
Code: Select all
----------------------------------
Running callbacks:
hash: OTc2ZTAzMDgzNTI5ZmEyOTY5SHNRT3dSRi9wb012bTVaZEtLUjRqZG4rSVRlem8vS3hjT1pRaVpENkZWWXRmQnI1MG9lRHhqcmIrbEs1VzZReFBFN1lja1dHL2xsemg5NENObTVRPT03D
$obj = json_decode(decrypt_data(OTc2ZTAzMDgzNTI5ZmEyOTY5SHNRT3dSRi9wb012bTVaZEtLUjRqZG4rSVRlem8vS3hjT1pRaVpENkZWWXRmQnI1MG9lRHhqcmIrbEs1VzZReFBFN1lja1dHL2xsemg5NENObTVRPT03D))
json_last_error: 0
NULL
Error - Could not find a host object in the hash provided
Processed 1 incoming emails
----------------------------------
So, it seems the hash does not have the ^M, but the decode is not finding the host object, for some reason.
Additionally -- and this goes back to something observed early on -- all works OK for a host down alert, where the only noticeable difference is the # of characters in the hash.
A snip from the cleaner.log, for a host ack which has a smaller # of chars in the hash:
Code: Select all
----------------------------------
Running callbacks:
hash: YzdjNjFmNDNhOGUzMGM1ZUI5QkZ2TjVXN3U4MlYvQXUyWjhkRzBxQnkxRFNENTBySnZ6NTBCSmJXNmM9
$obj = json_decode(decrypt_data(YzdjNjFmNDNhOGUzMGM1ZUI5QkZ2TjVXN3U4MlYvQXUyWjhkRzBxQnkxRFNENTBySnZ6NTBCSmJXNmM9))
json_last_error: 0
object(stdClass)#8 (1) {
["host"]=>
string(5) "dummy"
}
...
Is there any additional debugging we could add for original line 560, for the json_decode ?
Code: Select all
$obj = json_decode(decrypt_data($hash));
To recap, here is the current state of my xicore.inc.php vs the original:
Code: Select all
# diff xicore.inc.php.orig xicore.inc.php
560a561,565
> echo "hash: " . $hash . "\n";
> echo "\$obj = json_decode(decrypt_data($hash))\n";
> $error = json_last_error();
> echo "json_last_error: " . $error . "\n";
> var_dump($obj);
587c592
< $msg = substr($email['body'], 0, $msg_end);
---
> $msg = preg_replace("/[\\r\\n]+/", "\n", substr($email['body'], 0, $msg_end));
Thanks again for your help with this.