[PHP-BUG] Bug #64889 [NEW]: printf inconsistent parsing format string

2013-05-21 Thread xoneca+phpbugs at gmail dot com
From: xoneca+phpbugs at gmail dot com
Operating system: Linux 2.6.32-46-generic
PHP version:  5.3.25
Package:  Scripting Engine problem
Bug Type: Bug
Bug description:printf inconsistent parsing format string

Description:

`printf` is inconsistent parsing the format string. Sometimes it throws a
warning, and sometimes does not.

`printf` doesn't seem to like very much single `%` chars and gets crazy.

Depending on the arguments number, it will print something, or nothing.

Test script:
---
printf( '% % % %'); // or echo sprintf(...);
printf( '% % % %', 10);
printf( '% % % %', 10, 20);
printf( '% % % %', 10, 20, 30);
printf( '% % % %', 10, 20, 30, 40);
printf( '% % % %', 10, 20, 30, 40, 50);
// Another example:
printf( '% ## %d ## % ## %d ## %d', 10, 20, 30, 40, 50);


Expected result:

Throwing a warning at each call, or none at all. But not only sometimes.

Actual result:
--
php > printf( '% % % %');
PHP Warning:  printf(): Too few arguments in php shell code on line 1
php > printf( '% % % %', 10);
PHP Warning:  printf(): Too few arguments in php shell code on line 1
php > printf( '% % % %', 10, 20);
% %
php > printf( '% % % %', 10, 20, 30);
% %
php > printf( '% % % %', 10, 20, 30, 40);
% %
php > printf( '% % % %', 10, 20, 30, 40, 50);
% %
php > // Another example:
php > echo sprintf( '% ## %d ## % ## %d ## %d', 10, 20, 30, 40, 50);
# 20 ## # 40 ## 50

-- 
Edit bug report at https://bugs.php.net/bug.php?id=64889&edit=1
-- 
Try a snapshot (PHP 5.4):   
https://bugs.php.net/fix.php?id=64889&r=trysnapshot54
Try a snapshot (PHP 5.3):   
https://bugs.php.net/fix.php?id=64889&r=trysnapshot53
Try a snapshot (trunk): 
https://bugs.php.net/fix.php?id=64889&r=trysnapshottrunk
Fixed in SVN:   https://bugs.php.net/fix.php?id=64889&r=fixed
Fixed in release:   https://bugs.php.net/fix.php?id=64889&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=64889&r=needtrace
Need Reproduce Script:  https://bugs.php.net/fix.php?id=64889&r=needscript
Try newer version:  https://bugs.php.net/fix.php?id=64889&r=oldversion
Not developer issue:https://bugs.php.net/fix.php?id=64889&r=support
Expected behavior:  https://bugs.php.net/fix.php?id=64889&r=notwrong
Not enough info:
https://bugs.php.net/fix.php?id=64889&r=notenoughinfo
Submitted twice:
https://bugs.php.net/fix.php?id=64889&r=submittedtwice
register_globals:   https://bugs.php.net/fix.php?id=64889&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=64889&r=php4
Daylight Savings:   https://bugs.php.net/fix.php?id=64889&r=dst
IIS Stability:  https://bugs.php.net/fix.php?id=64889&r=isapi
Install GNU Sed:https://bugs.php.net/fix.php?id=64889&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=64889&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=64889&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=64889&r=mysqlcfg



Bug #64889 [Opn]: printf inconsistent parsing format string

2013-05-21 Thread xoneca+phpbugs at gmail dot com
Edit report at https://bugs.php.net/bug.php?id=64889&edit=1

 ID: 64889
 User updated by:xoneca+phpbugs at gmail dot com
 Reported by:xoneca+phpbugs at gmail dot com
 Summary:printf inconsistent parsing format string
 Status: Open
 Type:   Bug
 Package:Scripting Engine problem
 Operating System:   Linux 2.6.32-46-generic
-PHP Version:5.3.25
+PHP Version:5.4.15
 Block user comment: N
 Private report: N

 New Comment:

Tested on latest stable and the result was the same.


Previous Comments:

[2013-05-21 15:21:33] xoneca+phpbugs at gmail dot com

Description:

`printf` is inconsistent parsing the format string. Sometimes it throws a 
warning, and sometimes does not.

`printf` doesn't seem to like very much single `%` chars and gets crazy.

Depending on the arguments number, it will print something, or nothing.

Test script:
---
printf( '% % % %'); // or echo sprintf(...);
printf( '% % % %', 10);
printf( '% % % %', 10, 20);
printf( '% % % %', 10, 20, 30);
printf( '% % % %', 10, 20, 30, 40);
printf( '% % % %', 10, 20, 30, 40, 50);
// Another example:
printf( '% ## %d ## % ## %d ## %d', 10, 20, 30, 40, 50);


Expected result:

Throwing a warning at each call, or none at all. But not only sometimes.

Actual result:
--
php > printf( '% % % %');
PHP Warning:  printf(): Too few arguments in php shell code on line 1
php > printf( '% % % %', 10);
PHP Warning:  printf(): Too few arguments in php shell code on line 1
php > printf( '% % % %', 10, 20);
% %
php > printf( '% % % %', 10, 20, 30);
% %
php > printf( '% % % %', 10, 20, 30, 40);
% %
php > printf( '% % % %', 10, 20, 30, 40, 50);
% %
php > // Another example:
php > echo sprintf( '% ## %d ## % ## %d ## %d', 10, 20, 30, 40, 50);
# 20 ## # 40 ## 50






-- 
Edit this bug report at https://bugs.php.net/bug.php?id=64889&edit=1


Bug #64889 [Nab]: printf inconsistent parsing format string

2013-07-21 Thread xoneca+phpbugs at gmail dot com
Edit report at https://bugs.php.net/bug.php?id=64889&edit=1

 ID: 64889
 User updated by:xoneca+phpbugs at gmail dot com
 Reported by:xoneca+phpbugs at gmail dot com
 Summary:printf inconsistent parsing format string
 Status: Not a bug
 Type:   Bug
 Package:Scripting Engine problem
 Operating System:   Linux 2.6.32-46-generic
 PHP Version:5.4.15
 Block user comment: N
 Private report: N

 New Comment:

I know '%' never should be used alone. I just found out that I mistakenly 
dropped the following letter and PHP just didn't complain. When I realized 
that, I started doing more tests.

I think PHP should throw a warning or something if it finds any non-escaped '%'.


Previous Comments:

[2013-07-21 17:55:22] ar...@php.net

As documented, use %% to represent a literal % in the format string.

----
[2013-05-21 16:01:46] xoneca+phpbugs at gmail dot com

Tested on latest stable and the result was the same.

----
[2013-05-21 15:21:33] xoneca+phpbugs at gmail dot com

Description:

`printf` is inconsistent parsing the format string. Sometimes it throws a 
warning, and sometimes does not.

`printf` doesn't seem to like very much single `%` chars and gets crazy.

Depending on the arguments number, it will print something, or nothing.

Test script:
---
printf( '% % % %'); // or echo sprintf(...);
printf( '% % % %', 10);
printf( '% % % %', 10, 20);
printf( '% % % %', 10, 20, 30);
printf( '% % % %', 10, 20, 30, 40);
printf( '% % % %', 10, 20, 30, 40, 50);
// Another example:
printf( '% ## %d ## % ## %d ## %d', 10, 20, 30, 40, 50);


Expected result:

Throwing a warning at each call, or none at all. But not only sometimes.

Actual result:
--
php > printf( '% % % %');
PHP Warning:  printf(): Too few arguments in php shell code on line 1
php > printf( '% % % %', 10);
PHP Warning:  printf(): Too few arguments in php shell code on line 1
php > printf( '% % % %', 10, 20);
% %
php > printf( '% % % %', 10, 20, 30);
% %
php > printf( '% % % %', 10, 20, 30, 40);
% %
php > printf( '% % % %', 10, 20, 30, 40, 50);
% %
php > // Another example:
php > echo sprintf( '% ## %d ## % ## %d ## %d', 10, 20, 30, 40, 50);
# 20 ## # 40 ## 50






-- 
Edit this bug report at https://bugs.php.net/bug.php?id=64889&edit=1