[PHP-DEV] http arrays

2007-04-27 Thread elias

Hi,

why has the support for http arrays (bracket syntax) been removed in PHP 
 5.1.3 ? Yes [] not allowed by according RFC, but is that a reason for 
an BC break? Is it an accident or harassment?


patrick

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] http arrays

2007-04-27 Thread Antony Dovgal

On 04/27/2007 04:35 PM, elias wrote:

Hi,

why has the support for http arrays (bracket syntax) been removed in PHP 
  5.1.3 ? Yes [] not allowed by according RFC, but is that a reason for 
an BC break? Is it an accident or harassment?


What are you talking about?

--
Wbr, 
Antony Dovgal


--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DEV] [patch] Dynamic access of static members/methods, and constants

2007-04-27 Thread Etienne Kneuss

Hi,

I've already proposed that 1-2 months ago, but now seems to be a good 
time to discuss new things, so let's try again:


I believe it would be nice to be able to dynamically reference static
members, constants, and methods.

Currently, there is no way to do that and the only way would be to
create a static method and use call_user_func(array($classname, 'getThat'));

In other words:

class A {
public static $foo = 'value1';
const  gee = 'value2';
public static function bar() { return 'value3'; }

// old way:
public static function getFoo() { return self::$foo; }
public static function getGee() { return self::gee; }

}

$classname = 'A';
echo $classname::$foo;  // value1
echo $classname::gee;   // value2
echo $classname::bar(); // value3

// --- instead of: ---

$classname = 'A';
echo call_user_func(array($classname, 'getFoo')); // value1
echo call_user_func(array($classname, 'getGee')); // value2
echo call_user_func(array($classname, 'bar'));// value3

which is quite slow.

Please take a look at the patch[1] I made for it. Comments would be 
appreciated!


Regards,


1: http://patches.colder.ch/Zend/dynamic-static-calls.patch?markup

--
Etienne Kneuss
http://www.colder.ch
[EMAIL PROTECTED]

Men never do evil so completely and cheerfully as
when they do it from a religious conviction.
-- Pascal
Index: Zend/zend_language_parser.y
===
RCS file: /repository/ZendEngine2/zend_language_parser.y,v
retrieving revision 1.179
diff -u -r1.179 zend_language_parser.y
--- Zend/zend_language_parser.y 4 Mar 2007 16:25:57 -   1.179
+++ Zend/zend_language_parser.y 6 Mar 2007 14:43:49 -
@@ -642,6 +642,12 @@
|   fully_qualified_class_name T_PAAMAYIM_NEKUDOTAYIM 
variable_without_objects '(' { zend_do_end_variable_parse(BP_VAR_R, 0 
TSRMLS_CC); zend_do_begin_class_member_function_call($1, $3 TSRMLS_CC); }
function_call_parameter_list
')' { zend_do_end_function_call(NULL, $$, $6, 1, 1 
TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C);}
+   |   variable_class_name T_PAAMAYIM_NEKUDOTAYIM T_STRING '(' { 
zend_do_begin_class_member_function_call($1, $3 TSRMLS_CC); }
+   function_call_parameter_list
+   ')' { zend_do_end_function_call(NULL, $$, $6, 1, 1 
TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C);}
+   |   variable_class_name T_PAAMAYIM_NEKUDOTAYIM 
variable_without_objects '(' { zend_do_end_variable_parse(BP_VAR_R, 0 
TSRMLS_CC); zend_do_begin_class_member_function_call($1, $3 TSRMLS_CC); }
+   function_call_parameter_list
+   ')' { zend_do_end_function_call(NULL, $$, $6, 1, 1 
TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C);}
|   variable_without_objects  '(' { 
zend_do_end_variable_parse(BP_VAR_R, 0 TSRMLS_CC); 
zend_do_begin_dynamic_function_call($1 TSRMLS_CC); }
function_call_parameter_list ')'
{ zend_do_end_function_call($1, $$, $4, 0, 1 
TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C);}
@@ -795,6 +801,11 @@
 
 static_member:
fully_qualified_class_name T_PAAMAYIM_NEKUDOTAYIM 
variable_without_objects { $$ = $3; zend_do_fetch_static_member($$, $1 
TSRMLS_CC); }
+| variable_class_name T_PAAMAYIM_NEKUDOTAYIM variable_without_objects 
{ $$ = $3; zend_do_fetch_static_member($$, $1 TSRMLS_CC); }
+;
+
+variable_class_name:
+ reference_variable { zend_do_end_variable_parse(BP_VAR_R, 0 TSRMLS_CC); 
zend_do_fetch_class($$, $1 TSRMLS_CC); }
 ;
 
 
@@ -930,6 +941,7 @@
 
 class_constant:
fully_qualified_class_name T_PAAMAYIM_NEKUDOTAYIM T_STRING { 
zend_do_fetch_constant($$, $1, $3, ZEND_RT TSRMLS_CC); }
+   | variable_class_name T_PAAMAYIM_NEKUDOTAYIM T_STRING { 
zend_do_fetch_constant($$, $1, $3, ZEND_RT TSRMLS_CC); }
 ;
 
 %%
Index: tests/lang/041.phpt
===
RCS file: tests/lang/041.phpt
diff -N tests/lang/041.phpt
--- /dev/null   1 Jan 1970 00:00:00 -
+++ tests/lang/041.phpt 6 Mar 2007 14:43:49 -
@@ -0,0 +1,14 @@
+--TEST--
+Dynamic access of static members
+--FILE--
+?php
+class A {
+publicstatic $b = 'foo';
+}
+$classname = 'A';
+echo $classname::$b;
+? 
+===DONE===
+--EXPECT--
+foo 
+===DONE===
Index: tests/lang/042.phpt
===
RCS file: tests/lang/042.phpt
diff -N tests/lang/042.phpt
--- /dev/null   1 Jan 1970 00:00:00 -
+++ tests/lang/042.phpt 6 Mar 2007 14:43:49 -
@@ -0,0 +1,14 @@
+--TEST--
+Dynamic access of constants
+--FILE--
+?php
+class A {
+const B = 'foo';
+}
+$classname = 'A';
+echo $classname::B;
+? 
+===DONE===
+--EXPECT--
+foo 
+===DONE===
Index: tests/lang/043.phpt
===
RCS file: tests/lang/043.phpt
diff -N tests/lang/043.phpt

Re: [PHP-DEV] [patch] Dynamic access of static members/methods, and constants

2007-04-27 Thread Edin Kadribasic
+1

Nice to be able to do this directly without resorting to call_user_func().

Edom


Etienne Kneuss wrote:
 Hi,
 
 I've already proposed that 1-2 months ago, but now seems to be a good
 time to discuss new things, so let's try again:
 
 I believe it would be nice to be able to dynamically reference static
 members, constants, and methods.
 
 Currently, there is no way to do that and the only way would be to
 create a static method and use call_user_func(array($classname,
 'getThat'));
 
 In other words:
 
 class A {
 public static $foo = 'value1';
 const  gee = 'value2';
 public static function bar() { return 'value3'; }
 
 // old way:
 public static function getFoo() { return self::$foo; }
 public static function getGee() { return self::gee; }
 
 }
 
 $classname = 'A';
 echo $classname::$foo;  // value1
 echo $classname::gee;   // value2
 echo $classname::bar(); // value3
 
 // --- instead of: ---
 
 $classname = 'A';
 echo call_user_func(array($classname, 'getFoo')); // value1
 echo call_user_func(array($classname, 'getGee')); // value2
 echo call_user_func(array($classname, 'bar'));// value3
 
 which is quite slow.
 
 Please take a look at the patch[1] I made for it. Comments would be
 appreciated!
 
 Regards,
 
 
 1: http://patches.colder.ch/Zend/dynamic-static-calls.patch?markup
 

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] [patch] Dynamic access of static members/methods, and constants

2007-04-27 Thread Antony Dovgal

On 04/27/2007 04:37 PM, Etienne Kneuss wrote:

Hi,

I've already proposed that 1-2 months ago, but now seems to be a good 
time to discuss new things, so let's try again:


I believe it would be nice to be able to dynamically reference static
members, constants, and methods.

Currently, there is no way to do that and the only way would be to
create a static method and use call_user_func(array($classname, 'getThat'));

In other words:


I'm +0 if it's for HEAD only.

Also I can see only two tests at the moment, we'll need MUCH more.
There are so much combinations to test: unicode  binary strings, numbers, 
arrays, objects, booleans etc. etc.

--
Wbr, 
Antony Dovgal


--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] http arrays

2007-04-27 Thread Jochem Maas
Antony Dovgal wrote:
 On 04/27/2007 04:35 PM, elias wrote:
 Hi,

 why has the support for http arrays (bracket syntax) been removed in
 PHP   5.1.3 ? Yes [] not allowed by according RFC, but is that a
 reason for an BC break? Is it an accident or harassment?
 
 What are you talking about?

probably a reference to the 'correct' but rather annoying BC break in 
http_build_query()
countless php apps make use of the ability of php to automatically convent 
get/post args
whose names are suffixed with square brackets into [sub]arrays in the relevant 
superglobal
array ... some of those app also make use of http_build_query() to 'cleanly' 
create
url query parameter strings that e.g.

$args = array('foo' = array('bar' = array(1,2,3), 'quz' = array(1,2,3)));
echo '/foo.php?'.http_build_query($args);


foo.php --- 8 ---

var_dump($_GET['foo']);


the var_dump() output used to be a neat nested array, but since 5.1.3 [although 
I remember
it as 5.1.6] http_build_query() makes htmlentities of the square brackets so 
therefore
the var_dump() gives you a string.

the workable 'fix' I have been using was to postprocess http_build_query() 
output
with the following - a 'solution' which makes my skin crawl just a little:


function http_build_query_unborker($s)
{
return preg_replace('#%5[bd](?=[^]*=)#ei', 'urldecode(\\0)', $s);
}



 

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] http arrays

2007-04-27 Thread Michael Wallner
Jochem Maas wrote:

 $args = array('foo' = array('bar' = array(1,2,3), 'quz' = array(1,2,3)));
 echo '/foo.php?'.http_build_query($args);
 
 
 foo.php --- 8 ---
 
 var_dump($_GET['foo']);
 
 
 the var_dump() output used to be a neat nested array, but since 5.1.3 
 [although I remember
 it as 5.1.6] http_build_query() makes htmlentities of the square brackets so 
 therefore
 the var_dump() gives you a string.

Works as expected here with v5.2

Regards,
-- 
Michael

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] [patch] Dynamic access of static members/methods, and constants

2007-04-27 Thread Tijnema !

On 4/27/07, Antony Dovgal [EMAIL PROTECTED] wrote:

On 04/27/2007 04:37 PM, Etienne Kneuss wrote:
 Hi,

 I've already proposed that 1-2 months ago, but now seems to be a good
 time to discuss new things, so let's try again:

 I believe it would be nice to be able to dynamically reference static
 members, constants, and methods.

 Currently, there is no way to do that and the only way would be to
 create a static method and use call_user_func(array($classname, 'getThat'));

 In other words:

I'm +0 if it's for HEAD only.

Also I can see only two tests at the moment, we'll need MUCH more.
There are so much combinations to test: unicode  binary strings, numbers, 
arrays, objects, booleans etc. etc.

--
Wbr,
Antony Dovgal


There are actually 3 tests

Tijnema

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] http arrays

2007-04-27 Thread Chad Daelhousen

Jochem Maas wrote:

the var_dump() output used to be a neat nested array, but since 5.1.3 [although 
I remember
it as 5.1.6] http_build_query() makes htmlentities of the square brackets so 
therefore
the var_dump() gives you a string.


It's in the changelog for 5.1.3:
* Fixed bug #36656 (http_build_query generates invalid URIs due to use 
of square brackets). (Mike)


It works as expected for me in 5.1.6, using URL-encoding rather than 
HTML-entities. (5.1.3 is badly broken anyway -- that's why 5.1.4 was 
released so soon after.) So there's no bug that I can see.


--
Chad Daelhousen
I've been programming for about 15 years, but it's only in the last
couple that I've come to a real understanding of it all.

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] http arrays

2007-04-27 Thread Jochem Maas
Michael Wallner wrote:
 Jochem Maas wrote:
 
 $args = array('foo' = array('bar' = array(1,2,3), 'quz' = array(1,2,3)));
 echo '/foo.php?'.http_build_query($args);


 foo.php --- 8 ---

 var_dump($_GET['foo']);


 the var_dump() output used to be a neat nested array, but since 5.1.3 
 [although I remember
 it as 5.1.6] http_build_query() makes htmlentities of the square brackets so 
 therefore
 the var_dump() gives you a string.
 
 Works as expected here with v5.2

I'll take your word on it (although I can't be sure exactly what it is that you 
expected),
which means the change has been reverted, or the input parsing stuff has been 
changed to
recognize escaped square brackets as if they were not escaped - I know for sure
that http_build_query() did escape quare brackets in 5.1.6 and that url query 
strings
that included escaped square brackets were not parsed into [nested] arrays.

a bug closed bug shows that this was changed for 5.1.3:

http://bugs.php.net/bug.php?id=36656



 
 Regards,

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] http arrays

2007-04-27 Thread Michael Wallner
Jochem Maas wrote:

 I'll take your word on it (although I can't be sure exactly what it is that 
 you expected),
 which means the change has been reverted, or the input parsing stuff has been 
 changed to
 recognize escaped square brackets as if they were not escaped - I know for 
 sure
 that http_build_query() did escape quare brackets in 5.1.6 and that url query 
 strings
 that included escaped square brackets were not parsed into [nested] arrays.

expected means that I get 

array(1) {
  [a]=
  array(1) {
[0]=
string(1) 1
  }
}


for get.php?a%5B%5D=1

-- 
Michael

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] http arrays

2007-04-27 Thread elias

Michael Wallner schrieb:

Jochem Maas wrote:

expected means that I get 


array(1) {
  [a]=
  array(1) {
[0]=
string(1) 1
  }
}


for get.php?a%5B%5D=1



damn! a vanilla example works fine for me too.
looks this happens only under certain conditions.
i'll look at it again and report if i can reproduce it.

thanks.

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] http arrays

2007-04-27 Thread Jochem Maas
sorry for the noise - having gone back and tested again I can
no longer reproduce my original problem (the OP seemingly had the
same issue).

whatever problem I was having, related to encoding of square brackets,
seems to have disappeared. sometimes I feel like I'm living in the twilight 
zone :-P

today there is no spoon.


Michael Wallner wrote:
 Jochem Maas wrote:
 
 I'll take your word on it (although I can't be sure exactly what it is that 
 you expected),
 which means the change has been reverted, or the input parsing stuff has 
 been changed to
 recognize escaped square brackets as if they were not escaped - I know for 
 sure
 that http_build_query() did escape quare brackets in 5.1.6 and that url 
 query strings
 that included escaped square brackets were not parsed into [nested] arrays.
 
 expected means that I get 
 
 array(1) {
   [a]=
   array(1) {
 [0]=
 string(1) 1
   }
 }
 
 
 for get.php?a%5B%5D=1
 

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] [patch] Dynamic access of static members/methods, and constants

2007-04-27 Thread David Coallier

+1

On 4/27/07, Tijnema ! [EMAIL PROTECTED] wrote:

On 4/27/07, Antony Dovgal [EMAIL PROTECTED] wrote:
 On 04/27/2007 04:37 PM, Etienne Kneuss wrote:
  Hi,
 
  I've already proposed that 1-2 months ago, but now seems to be a good
  time to discuss new things, so let's try again:
 
  I believe it would be nice to be able to dynamically reference static
  members, constants, and methods.
 
  Currently, there is no way to do that and the only way would be to
  create a static method and use call_user_func(array($classname, 'getThat'));
 
  In other words:

 I'm +0 if it's for HEAD only.

 Also I can see only two tests at the moment, we'll need MUCH more.
 There are so much combinations to test: unicode  binary strings, numbers, 
arrays, objects, booleans etc. etc.

 --
 Wbr,
 Antony Dovgal

There are actually 3 tests

Tijnema

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php





--
David Coallier,
Founder  Software Architect,
Agora Production (http://agoraproduction.com)
51.42.06.70.18

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DEV] JSON ampersand patch

2007-04-27 Thread Tyler Lawson
Hello,

I hope this is the right place for this, as I'd like to post a patch for
your consideration to the way the JSON handles ampersands.  I have had
problems sending JSON data back and forth over POST requests, where an
ampersand separates variables.  This patch will convert  into \u0026,
which will allow ampersands to travel freely and be parsed by any valid JSON
decoder.

This has been applied against php-5.2.1

--- json.c  2007-01-12 07:17:32.0 -0500
+++ my_json.c2007-04-27 15:12:44.0 -0400
@@ -301,6 +301,11 @@
 smart_str_appendl(buf, \\t, 2);
 }
 break;
+case '':
+{
+smart_str_appendl(buf, \\u0026, 6);
+}
+break;
 default:
 {
 if (us  ' ' || (us  127) == us)


Tyler

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] JSON ampersand patch

2007-04-27 Thread Antony Dovgal

On 04/27/2007 11:39 PM, Tyler Lawson wrote:

Hello,

I hope this is the right place for this, as I'd like to post a patch for
your consideration to the way the JSON handles ampersands.  I have had
problems sending JSON data back and forth over POST requests, where an
ampersand separates variables.  This patch will convert  into \u0026,
which will allow ampersands to travel freely and be parsed by any valid JSON
decoder.


I believe a short reproduce case would explain it better.


This has been applied against php-5.2.1

--- json.c  2007-01-12 07:17:32.0 -0500
+++ my_json.c2007-04-27 15:12:44.0 -0400
@@ -301,6 +301,11 @@
 smart_str_appendl(buf, \\t, 2);
 }
 break;
+case '':
+{
+smart_str_appendl(buf, \\u0026, 6);
+}
+break;
 default:
 {
 if (us  ' ' || (us  127) == us)


Tyler




--
Wbr, 
Antony Dovgal


--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP-DEV] JSON ampersand patch

2007-04-27 Thread Tyler Lawson
Alright, here goes.

post.php
?php
$data=data=This is my data  it is really great;
$json_data=json_encode($data);

$request =GET /test.php HTTP/1.0\n;
$request.=Host: something.com\n;
$request.=Content-Type: application/x-www-form-urlencoded\n
$request.=Content-Length: .strlen($json_data).\n;
$request.=\n;
$fsock=fsockopen(http://server.com ,80);
fwrite($fsock,$request);

$response=fread($fsock,2048);
echo $response;
?

test.php:
?php
var_dump($_POST);
?

Under php-5.2.1, the output would be:

array(4) {
  [data]=
  string(16) This is my data 

  [it is really great]=
  string(0) 
}

With this patch it would be:

array(4) {
  [data]=
  string(42) This is my data \u0026 it is really great
}


Tyler
-Original Message-
From: Antony Dovgal [mailto:[EMAIL PROTECTED] 
Sent: Friday, April 27, 2007 3:59 PM
To: Tyler Lawson
Cc: internals@lists.php.net
Subject: Re: [PHP-DEV] JSON ampersand patch

On 04/27/2007 11:39 PM, Tyler Lawson wrote:
 Hello,
 
 I hope this is the right place for this, as I'd like to post a patch for
 your consideration to the way the JSON handles ampersands.  I have had
 problems sending JSON data back and forth over POST requests, where an
 ampersand separates variables.  This patch will convert  into \u0026,
 which will allow ampersands to travel freely and be parsed by any valid
JSON
 decoder.

I believe a short reproduce case would explain it better.
 
 This has been applied against php-5.2.1
 
 --- json.c  2007-01-12 07:17:32.0 -0500
 +++ my_json.c2007-04-27 15:12:44.0 -0400
 @@ -301,6 +301,11 @@
  smart_str_appendl(buf, \\t, 2);
  }
  break;
 +case '':
 +{
 +smart_str_appendl(buf, \\u0026, 6);
 +}
 +break;
  default:
  {
  if (us  ' ' || (us  127) == us)
 
 
 Tyler
 


-- 
Wbr, 
Antony Dovgal

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] JSON ampersand patch

2007-04-27 Thread Rasmus Lerdorf
Well, your example is weird in many ways.  First, you don't ever send
$json_data over the wire as far as I can tell.  And if you did, are you
actually sending it in form-urlencoded format as the mime-type you
specified indicated?  As in, something like:

  $request .= json_data=.urlencode($json_data);

This will automatically get decoded by PHP because that's what
urlencoded form data is supposed to look like.

It is quite likely that you aren't actually sending valid urlencoded
data and just sending the raw jsonn data over the wire in which case you
should be using application/json as your mime type and fetch it directly
from the raw post data.

-Rasmus

Tyler Lawson wrote:
 Alright, here goes.
 
 post.php
 ?php
 $data=data=This is my data  it is really great;
 $json_data=json_encode($data);
 
 $request =GET /test.php HTTP/1.0\n;
 $request.=Host: something.com\n;
 $request.=Content-Type: application/x-www-form-urlencoded\n
 $request.=Content-Length: .strlen($json_data).\n;
 $request.=\n;
 $fsock=fsockopen(http://server.com ,80);
 fwrite($fsock,$request);
 
 $response=fread($fsock,2048);
 echo $response;
 ?
 
 test.php:
 ?php
 var_dump($_POST);
 ?
 
 Under php-5.2.1, the output would be:
 
 array(4) {
   [data]=
   string(16) This is my data 
 
   [it is really great]=
   string(0) 
 }
 
 With this patch it would be:
 
 array(4) {
   [data]=
   string(42) This is my data \u0026 it is really great
 }
 
 
 Tyler
 -Original Message-
 From: Antony Dovgal [mailto:[EMAIL PROTECTED] 
 Sent: Friday, April 27, 2007 3:59 PM
 To: Tyler Lawson
 Cc: internals@lists.php.net
 Subject: Re: [PHP-DEV] JSON ampersand patch
 
 On 04/27/2007 11:39 PM, Tyler Lawson wrote:
 Hello,

 I hope this is the right place for this, as I'd like to post a patch for
 your consideration to the way the JSON handles ampersands.  I have had
 problems sending JSON data back and forth over POST requests, where an
 ampersand separates variables.  This patch will convert  into \u0026,
 which will allow ampersands to travel freely and be parsed by any valid
 JSON
 decoder.
 
 I believe a short reproduce case would explain it better.
  
 This has been applied against php-5.2.1

 --- json.c  2007-01-12 07:17:32.0 -0500
 +++ my_json.c2007-04-27 15:12:44.0 -0400
 @@ -301,6 +301,11 @@
  smart_str_appendl(buf, \\t, 2);
  }
  break;
 +case '':
 +{
 +smart_str_appendl(buf, \\u0026, 6);
 +}
 +break;
  default:
  {
  if (us  ' ' || (us  127) == us)


 Tyler

 
 

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DEV] CVS Account Request: lalabouya

2007-04-27 Thread ajaoud mohamed
music amzigh

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP-DEV] JSON ampersand patch

2007-04-27 Thread Tyler Lawson
That was just a crappy test case I put together really quickly, but I do see
you are correct.  I was so focused on ampersands being the issue that the
simple and correct solution eluded me.

Sorry to bother you.

Tyler Lawson

-Original Message-
From: Rasmus Lerdorf [mailto:[EMAIL PROTECTED] 
Sent: Friday, April 27, 2007 4:26 PM
To: Tyler Lawson
Cc: 'Antony Dovgal'; internals@lists.php.net
Subject: Re: [PHP-DEV] JSON ampersand patch

Well, your example is weird in many ways.  First, you don't ever send
$json_data over the wire as far as I can tell.  And if you did, are you
actually sending it in form-urlencoded format as the mime-type you
specified indicated?  As in, something like:

  $request .= json_data=.urlencode($json_data);

This will automatically get decoded by PHP because that's what
urlencoded form data is supposed to look like.

It is quite likely that you aren't actually sending valid urlencoded
data and just sending the raw jsonn data over the wire in which case you
should be using application/json as your mime type and fetch it directly
from the raw post data.

-Rasmus

Tyler Lawson wrote:
 Alright, here goes.
 
 post.php
 ?php
 $data=data=This is my data  it is really great;
 $json_data=json_encode($data);
 
 $request =GET /test.php HTTP/1.0\n;
 $request.=Host: something.com\n;
 $request.=Content-Type: application/x-www-form-urlencoded\n
 $request.=Content-Length: .strlen($json_data).\n;
 $request.=\n;
 $fsock=fsockopen(http://server.com ,80);
 fwrite($fsock,$request);
 
 $response=fread($fsock,2048);
 echo $response;
 ?
 
 test.php:
 ?php
 var_dump($_POST);
 ?
 
 Under php-5.2.1, the output would be:
 
 array(4) {
   [data]=
   string(16) This is my data 
 
   [it is really great]=
   string(0) 
 }
 
 With this patch it would be:
 
 array(4) {
   [data]=
   string(42) This is my data \u0026 it is really great
 }
 
 
 Tyler
 -Original Message-
 From: Antony Dovgal [mailto:[EMAIL PROTECTED] 
 Sent: Friday, April 27, 2007 3:59 PM
 To: Tyler Lawson
 Cc: internals@lists.php.net
 Subject: Re: [PHP-DEV] JSON ampersand patch
 
 On 04/27/2007 11:39 PM, Tyler Lawson wrote:
 Hello,

 I hope this is the right place for this, as I'd like to post a patch for
 your consideration to the way the JSON handles ampersands.  I have had
 problems sending JSON data back and forth over POST requests, where an
 ampersand separates variables.  This patch will convert  into
\u0026,
 which will allow ampersands to travel freely and be parsed by any valid
 JSON
 decoder.
 
 I believe a short reproduce case would explain it better.
  
 This has been applied against php-5.2.1

 --- json.c  2007-01-12 07:17:32.0 -0500
 +++ my_json.c2007-04-27 15:12:44.0 -0400
 @@ -301,6 +301,11 @@
  smart_str_appendl(buf, \\t, 2);
  }
  break;
 +case '':
 +{
 +smart_str_appendl(buf, \\u0026, 6);
 +}
 +break;
  default:
  {
  if (us  ' ' || (us  127) == us)


 Tyler

 
 

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DEV] CVS Account Request: sepilrat

2007-04-27 Thread Juan Pablo Rossi
to make a version server

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php