Note that drupal uses \\\ instead of \\\\, but it's OK with current PHP, so it's not a bug right now. The problem here is drupal doesn't consider the situation of formatted JSON with slashes so it just adding another slash to the existing slash, making node parsing it to \ after popen.
There are two ways to fix this, either using PHP or node.js. I am proposing adding option JSON_UNESCAPED_SLASHES to json_encode to avoid such bugs.
In the current version, the following codes output a PDF that has its header wrongly generated.
After carefully checked the source code, I found the problem:
In
escapeShellArgument()
, the process would be:Note that drupal uses
\\\
instead of\\\\
, but it's OK with current PHP, so it's not a bug right now. The problem here is drupal doesn't consider the situation of formatted JSON with slashes so it just adding another slash to the existing slash, making node parsing it to\
afterpopen
.There are two ways to fix this, either using PHP or node.js. I am proposing adding option JSON_UNESCAPED_SLASHES to
json_encode
to avoid such bugs.Here is the outcome: