php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #68116 The code is same but it display different output
Submitted: 2014-09-29 12:28 UTC Modified: 2014-09-30 07:04 UTC
From: kabir dot pust at gmail dot com Assigned:
Status: Not a bug Package: Output Control
PHP Version: 5.4.33 OS: Ubuntu
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: kabir dot pust at gmail dot com
New email:
PHP Version: OS:

Further comment on this bug is unnecessary.

 

 [2014-09-29 12:28 UTC] kabir dot pust at gmail dot com
Description:
------------
    <?php
     
    echo $a = urlencode(base64_encode('fazlul')).' ';
    echo $str = @iconv('UTF-8', 'UTF-8//IGNORE', $a).' ';
    echo $c = urldecode(base64_decode($str));
     
    echo "\r\n\r\n";
     
    echo $a = urlencode(base64_encode('masud')).' ';//same for karim
    echo $str = @iconv('UTF-8', 'UTF-8//IGNORE', $a).' ';
    echo $c = urldecode(base64_decode($str));

Test script:
---------------
Same process but the output is different.

Expected result:
----------------


input: fazlul
output: fazlul

But,

input: masud 
output: masud

Actual result:
--------------
input: fazlul
output: fazlul

But,

input: masud 
output: masud7


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-09-29 12:49 UTC] leigh@php.net
-Status: Open +Status: Not a bug
 [2014-09-29 12:49 UTC] leigh@php.net
Sorry but this is not a bug.

The base64_encoded version of 'masud' will have a single equals sign at the end for padding.

When you urlencode this it will be converted to '%3D',

bWFzdWQ= -> bWFzdWQ%3D

You have changed the encoding, and have changed the value represented by this encoding.

base64_decode is behaving correctly in this case.

Thank you for your interest in PHP.
 [2014-09-30 03:30 UTC] kabir dot pust at gmail dot com
Could you clear this ? 

I need to remove(=) equal sign from the input url. How can I make this ?
 [2014-09-30 07:04 UTC] leigh@php.net
-Block user comment: No +Block user comment: Yes
 [2014-09-30 07:04 UTC] leigh@php.net
This is a bug report system, not a support forum. There are various methods for obtaining support documented at: http://php.net/support.php - but you'll probably get results faster by using a search engine.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 13:01:29 2024 UTC