View Issue Details

IDProjectCategoryView StatusLast Update
0002257XdebugUncategorizedpublic2024-05-10 15:19
Reporternym Assigned Toderick  
PrioritynormalSeveritymajorReproducibilityalways
Status feedbackResolutionopen 
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.

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