[Patch] XML_RPC NAN/INF handling
| From: | Kees Bos | Date: | Mon, 18 Oct 2004 09:26:50 +0000 |
| Subject: | [Patch] XML_RPC NAN/INF handling | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-33919@lists.php.net to get a copy of this message | ||
Hi,
The XML_RPC package doesn't handle the doubles NAN and INF.
I've attached a patch that enables an xmlrpc client to receive
the nan/inf values.
I added some code to the functin XML_RPC_ee to catch a nan or inf
(case insensitive) and to replace these by the php uppercase values
NAN or INF.
Cheers,
Kees
--
ZXFactory BV
Telefoon: +31(0)318 693 111
Fax: +31 (0)318 693 042
Mobiel: +31 (0)6 2907 7587
E-mail: <mailto:k.bos@zx.nl> k.bos@zx.nl
Bezoek onze website: <http://www.zx.nl/> www.zx.nl
ICT-services: our profession, your solution
? XML_RPC.diff Index: RPC.php =================================================================== RCS file: /repository/pear/XML_RPC/RPC.php,v retrieving revision 1.26 diff -u -r1.26 RPC.php --- RPC.php 6 Oct 2004 19:03:32 -0000 1.26 +++ RPC.php 18 Oct 2004 09:07:51 -0000 @@ -270,8 +270,14 @@ // we have an I4, INT or a DOUBLE // we must check that only 0123456789-.<space> are characters here if (!ereg("^[+-]?[0123456789 \t\.]+$", $XML_RPC_xh[$parser]['ac'])) { - PEAR::raiseError("Non-numeric value received in INT or DOUBLE", XML_RPC_ERROR_NON_NUMERIC_FOUND); - $XML_RPC_xh[$parser]['st'] .= "ERROR_NON_NUMERIC_FOUND"; + if ($name=="DOUBLE" && + (strcasecmp($XML_RPC_xh[$parser]['ac'], 'nan') == 0 || + strcasecmp($XML_RPC_xh[$parser]['ac'], 'inf') == 0)) { + $XML_RPC_xh[$parser]['st'] .= strtoupper($XML_RPC_xh[$parser]['ac']); + } else { + PEAR::raiseError("Non-numeric value received in INT or DOUBLE", XML_RPC_ERROR_NON_NUMERIC_FOUND); + $XML_RPC_xh[$parser]['st'] .= "ERROR_NON_NUMERIC_FOUND"; + } } else { // it's ok, add it on $XML_RPC_xh[$parser]['st'] .= $XML_RPC_xh[$parser]['ac'];
? XML_RPC.diff Index: RPC.php =================================================================== RCS file: /repository/pear/XML_RPC/RPC.php,v retrieving revision 1.26 diff -u -r1.26 RPC.php --- RPC.php 6 Oct 2004 19:03:32 -0000 1.26 +++ RPC.php 18 Oct 2004 09:07:51 -0000 @@ -270,8 +270,14 @@ // we have an I4, INT or a DOUBLE // we must check that only 0123456789-.<space> are characters here if (!ereg("^[+-]?[0123456789 \t\.]+$", $XML_RPC_xh[$parser]['ac'])) { - PEAR::raiseError("Non-numeric value received in INT or DOUBLE", XML_RPC_ERROR_NON_NUMERIC_FOUND); - $XML_RPC_xh[$parser]['st'] .= "ERROR_NON_NUMERIC_FOUND"; + if ($name=="DOUBLE" && + (strcasecmp($XML_RPC_xh[$parser]['ac'], 'nan') == 0 || + strcasecmp($XML_RPC_xh[$parser]['ac'], 'inf') == 0)) { + $XML_RPC_xh[$parser]['st'] .= strtoupper($XML_RPC_xh[$parser]['ac']); + } else { + PEAR::raiseError("Non-numeric value received in INT or DOUBLE", XML_RPC_ERROR_NON_NUMERIC_FOUND); + $XML_RPC_xh[$parser]['st'] .= "ERROR_NON_NUMERIC_FOUND"; + } } else { // it's ok, add it on $XML_RPC_xh[$parser]['st'] .= $XML_RPC_xh[$parser]['ac'];