View Issue Details

IDProjectCategoryView StatusLast Update
0002257XdebugUncategorizedpublic2024-08-07 19:37
Reporternym Assigned Toderick  
PrioritynormalSeveritymajorReproducibilityalways
Status assignedResolutionopen 
Product Version3.2.0 
Summary0002257: xdebug is base64 encoding long strings, resulting in code fault
Description

I have a very long string in hexadecimal format, convert it with hex2bin at this point Xdebug on Sublime Text is showing me the variable base64 encoded for some reason, if I echo the variable it prints correctly, if I try to $r=json_decode($r, true); it returns null, because it assumed the variable is really its base64 encoded representation.

Steps To Reproduce
<!doctype html>
<html lang="en">
    <body>      

<?php
$r = $_GET['r']; //r is any string in hex (obtained with bin2hex in javascript, see notes) format containing special characters such as ÉGOÏSTE 

$r = hex2bin($r);       

//here xdebug on sublime text show it as a base64 encoded string

echo $r;

$r=json_decode($r, true); //since the variable is now base64 and not jus rrepresented as that, this returns null

//the code fail here since there is a null check.

//the problem is xdebug represent long text variables as base64 encoded (probably due to weird letters used??) then assume the representation is the real value of the variable. Passing EGOISTE doesn't trigger the bug.

?>
    </body>

 </html>        
Additional Information
//javascript code used to bin2hex

function bin2hex (bin)
{

  var i = 0, l = bin.length, chr, hex = ''

  for (i; i < l; ++i)
  {

    chr = bin.charCodeAt(i).toString(16)

    hex += chr.length < 2 ? '0' + chr : chr

  }

  return hex

}
Tags3.0.2
Operating SystemWindows 10 x64
PHP Version8.2.0-8.2.9

Activities

nym

2024-03-30 21:45

reporter   ~0006887

The problem seems to be PHP related, can someone confirm?

derick

2024-04-15 12:36

administrator   ~0006899

Can you attach the Xdebug debugging log, and the files that you used to this report? You can learn at https://xdebug.org/reporting-bugs#step-debugger on how to create a debugging log.

derick

2024-05-06 10:23

administrator   ~0006932

Can you provide the requested feedback please?

nym

2024-05-06 16:47

reporter   ~0006949

@derick

Hi, I'm sorry I no longer have the files as I had to adapt the code, no logs either but I have pasted the very same minimal code to reproduce the bug, if this can help I was using Xdebug with the equivalent plug-in for Sublime Text, back then I remember I confirmed multiple times it is showing the string as described while not actually being Base64 however at some point it was read as a real Base64 the problem was most probably caused by text containing ÉGOÏSTE I had to rewrite the client part to normalize strings and only accept "normal" letters and convert this to EGOISTE this solved the bug on Xdebug and/or PHP whoever is at this. I noticed the snippet above stripped the opening tag, not sure why it didn't let me paste the snippet correctly. Was you able to run the above code in the same setup and replicated the issue?

derick

2024-05-10 15:19

administrator   ~0006952

I wouldn't have asked for the logs if I could reproduce it with your example — but that is mostly because it's not a complete case. It's not something I can download and run, with it working immediately.

nym

2024-05-28 10:28

reporter   ~0006962

@derick

Ok, I'll create a project with minimum code to replicate the issue. Will update once ready.

derick

2024-06-05 09:04

administrator   ~0006965

Hi @nym,

Did you find the time to do this?

cheers,
Derick

nym

2024-06-05 14:29

reporter   ~0006968

@derick,

I was drained in a work I had to deliver, I'll do this test project on saturday at the latest and upload it here.

nym

2024-06-07 10:03

reporter   ~0006970

@derick,

Wow I wrote a lenghty text and token expired, I'll be more concise, download the zip and read the comments inside to fill-in-the-blanks before you test, load the client manifest as a temporary add-on for firefox, as soon and you add it, the plug-in will open a new window to a website with ?r parameter the website must be your XAMPP configured endpoint.

See the comments inside the .js (client) and php (server) files and if it is not clear let me know.

xdebug_test.zip (3,219 bytes)

derick

2024-07-18 13:44

administrator   ~0007014

I don't use Sublime, and I don't quite understand why you're asking me to install a temporary Firefox plugin?

There should be no need for this surely, as Xdebug is a debugger for PHP - it doesn't interact with anything JavaScript related either.

nym

2024-07-18 14:07

reporter   ~0007016

@derick,

It was to reproduce my environment entirely. The temporary plug-in is how I send the URL call to the PHP, the JavaScript portion is on the plug-in to trigger the PHP. Once there and using Xdebug plug-in for Sublime, you can replicate the issue. The plug-in for Sublime is a "glue" to have Xdebug "talk" to Sublime and debug using it.

derick

2024-07-18 16:22

administrator   ~0007021

I have no idea what you just said.

Xdebug does not interact with JavaScript. JavaScript might start a request, but then Xdebug is only concerned with the request once it hits the web server and PHP.

Show me the interaction between your HTTP client and your Webserver/PHP? Tools like Wireshark can do that.

nym

2024-07-18 16:40

reporter   ~0007022

@derick,

That's correct, it was to reproduce my environment. On May 6th you asked for a sample project with minimum code to reproduce the bug, I provided you this and instructions to replicate. The JavaScript is how I create the string passed to the PHP, you don't need to run the plug-in very time but only once to generate the string for you, then you can set this string to start your PHP project and see that once the Xdebug hits sublime debug, the error will raise.

derick

2024-08-07 13:36

administrator   ~0007033

So please provide the bare minimum. I do not need any plugins for normal debugging, so why do I need that now. I also don't have Sublime. If there is a bug in Xdebug, then you must be able to reproduce it with simple HTTP requests.

nym

2024-08-07 14:02

reporter   ~0007039

@derick,

The plug-in might be a factor in how it encodes the string, I'd suggest you have the plug-in (which is itself a bare minimum) generate the relevant string and then use it to call the php script as an ? argument for you debug purposes. Sublime should not the cause, but Xdebug for Sublime might be part of the process. If you want to reproduce my environment then use the provided setup, deducting from it will be something we can do once you have replicated the bug with the same situation, then we can narrow it deducting Sublime / plug-in etc..

derick

2024-08-07 15:25

administrator   ~0007042

How the plugin encodes the string is not of my concern. It might as well be a bug there.

I asked before (https://bugs.xdebug.org/view.php?id=2257#c7021) to provide the network traffic to show your case. You can use Wireshark to do that. Feel free to attach the generated pcapng file.

If you're not willing to demonstrate that it is Xdebug that is the problem, then I won't be able to assist further.

nym

2024-08-07 19:37

reporter   ~0007043

@derick,

Sound like you prefer to hide the bug under the carpet and pretend everything is fine. When you do testing the first step is to replicate the environment, then the user behavior. After this, you can subtract elements and narrrow it down, not before, this is general testing not rocket science. I provided you with the minimal code to replicate my environment and beharior. It is up to you if you prefer to lift the carpet and hide this or do some real testing. Either way I'm done here. Best.

Issue History

Date Modified Username Field Change
2024-03-30 21:27 nym New Issue
2024-03-30 21:27 nym Tag Attached: 3.0.2
2024-03-30 21:45 nym Note Added: 0006887
2024-04-15 12:35 derick Steps to Reproduce Updated
2024-04-15 12:35 derick Additional Information Updated
2024-04-15 12:36 derick Assigned To => derick
2024-04-15 12:36 derick Status new => feedback
2024-04-15 12:36 derick Note Added: 0006899
2024-05-06 10:23 derick Note Added: 0006932
2024-05-06 16:47 nym Note Added: 0006949
2024-05-06 16:47 nym Status feedback => assigned
2024-05-10 15:19 derick Status assigned => feedback
2024-05-10 15:19 derick Note Added: 0006952
2024-05-28 10:28 nym Note Added: 0006962
2024-05-28 10:28 nym Status feedback => assigned
2024-06-05 09:04 derick Status assigned => feedback
2024-06-05 09:04 derick Note Added: 0006965
2024-06-05 14:29 nym Note Added: 0006968
2024-06-05 14:29 nym Status feedback => assigned
2024-06-07 10:03 nym Note Added: 0006970
2024-06-07 10:03 nym File Added: xdebug_test.zip
2024-07-18 13:44 derick Status assigned => feedback
2024-07-18 13:44 derick Note Added: 0007014
2024-07-18 14:07 nym Note Added: 0007016
2024-07-18 14:07 nym Status feedback => assigned
2024-07-18 16:22 derick Status assigned => feedback
2024-07-18 16:22 derick Note Added: 0007021
2024-07-18 16:40 nym Note Added: 0007022
2024-07-18 16:40 nym Status feedback => assigned
2024-08-07 13:36 derick Status assigned => feedback
2024-08-07 13:36 derick Note Added: 0007033
2024-08-07 14:02 nym Note Added: 0007039
2024-08-07 14:02 nym Status feedback => assigned
2024-08-07 15:25 derick Note Added: 0007042
2024-08-07 15:25 derick Status assigned => feedback
2024-08-07 19:37 nym Note Added: 0007043
2024-08-07 19:37 nym Status feedback => assigned