Open Source Training Seminar FreePBX Paid Support

Ticket #3031 (closed Bugs: fixed)

Opened 3 weeks ago

Last modified 3 weeks ago

PHPAGI Space Truncation Bug

Reported by: mwolf9 Assigned to: p_lindheimer
Priority: minor Milestone: 2.5
Component: Core - Users/Devices Version: 2.5-branch
Keywords: Cc:
Confirmation: Need testing SVN Revision (if applicable):
Backend Engine: All Backend Engine Version:

Description

Hello,

I have recently been integrating iSymphony with the newly added User Events described here http://www.freepbx.org/trac/ticket/2953. I recently ran into an issue involving the structure of the added UserEvent? calls. The call as it stands now looks like so:

$agi->exec("UserEvent", "UserDeviceAdded|Data:{$user},{$device}");

Which will result in a UserEvent? in the form:

Event: UserEvent
Privilege: ...
UserEvent: UserDeviceAdded
Data:100,100

The issue is that this event is malformed due to the lack of a space between Data: and 100,100. An appropriate event should look like:

Event: UserEvent
Privilege: ...
UserEvent: UserDeviceAdded
Data: 100,100

With the space after "Data:". Most AMI libraries, including the one we utilize for iSymphony will expect this space and attempt to remove it. In the case of the malformed event this will result in the data being interpreted as "00,100". The resolution for this is to change the call to look like so:

$agi->exec("UserEvent", "UserDeviceAdded|Data: {$user},{$device}");

With a space after "Data:". The issue is that phpagi will truncate the command at the space resulting in the call:

UserEvent(UserDeviceAdded|Data:)

Instead of:

UserEvent(UserDeviceAdded|Data: 100,100)

I believe the truncation occurs in the evaluate function in the phpagi library but I have been unable to track down the cause and provide a resolution as this function is quite complex. I have come up with a workaround for the issue by placing a dummy value in the UserEvent? call like so:

$agi->exec("UserEvent", "UserDeviceAdded|Data:*{$user},{$device}");

With this modification the Event is still malformed but our AMI library will pull the data correctly. Any help with an appropriate fix would be greatly appreciated.

Change History

08/07/08 15:16:56 changed by p_lindheimer

  • confirmation changed from Unreviewed to Need testing.

mwolf9,
There are a couple versions of the same library that have unfortunately evolved separately over time. Before digging to deeply into this, can you do a sanity check. You will find a copy of phpagi-asmanager.php in /var/www/html/admin/common that is different then what is in /var/lib/asterisk/agi-bin. Can you try moving the one in the www directory into the agi directory and see if it still has the same error. It's possible it may have been fixed at some point. If it is, then we can figure out what the difference is and try to get that fix in. Otherwise, we'll have to dig deeper since the workaround is obviously not acceptable in the long term.

08/10/08 09:48:16 changed by p_lindheimer

mwolf9, ping - have you had a chance to check the above request?

08/10/08 16:13:12 changed by p_lindheimer

mwolf9,

I just realized the above was just for the manager part, not the phpagi.php part so ignore the test.

It turns out AGI is a bit sensitive to spaces, they seem to indicate the end of the command unless encapsulated in quotes. I'm not sure if that is an AGI bug or the nature of AGI.

08/10/08 16:14:48 changed by p_lindheimer

  • status changed from new to closed.
  • resolution set to fixed.

(In [6326]) fixes #3031 encapsulate UserEvent? command and args in quotes to keep AGI happy about spaces

Donate



Support
Download
Develop
Forums
News
Documentation
Paid Support
About

Paid Ads