5

If you look at what is it called when encrypt('a') + encrypt('a') == encrypt('aa')? you'll see the first code snippet is indented all weirdly, however, if you try to edit the post, you'll see that every line has the same indentation and that it's just crypto.stackexchange.org that's indenting it weirdly.

However, I'm not able to duplicate that issue on their meta or on this meta, as demonstrated thusly:

<?php
$mcrypt = mcrypt_module_open(MCRYPT_DES, '', MCRYPT_MODE_CBC, '');
mcrypt_generic_init($mcrypt, '@@@@@@@@', 'xxxxxxxx'); 
echo bin2hex(mcrypt_generic($mcrypt, 'dddddddd'));
echo "\r\n";
echo bin2hex(mcrypt_generic($mcrypt, 'dddddddd'));

So any idea what's up with the crypto.stackexchange.com post? Is this a SE bug? Maybe crypto.stackexchange.com is running an older version of SE than their meta or this SE is?

Screenshot:

enter image description here

  • Done. I'm using Chrome as well. Version 45.0.2454.85 m. On Windows 7. – neubert Sep 6 '15 at 16:29
  • Oh. I can see that too. I thought that you were talking about that line not formatted as code, and not about its indentation. Reproduced on chrome 45.0.2454.84 on android. – Spikatrix Sep 6 '15 at 16:34
6

As rene pointed out, the issue is related to MathJax. However, there is more involved here. MathJax does not render formulas within a code block, like $x^2$. It has not actually replaced anything in your code block.

The culprit is another script, custom-written for SE interface, which hides MathJax formulas from Markdown, so they do not get mangled by Markdown parser. It temporarily removes the bits between dollar signs, lets the Markdown parser run, and then puts them back.

In your situation, the parts between dollar signs contain 4 spaces at the beginning of some lines. Being temporarily hidden, these do not get processed by Markdown parser and therefore appear verbatim in your code block.

This should be considered a bug, although a fix isn't obvious.

A workaround is to use HTML for code formatting, avoiding Markdown->HTML conversion. The following renders correctly:

<pre><code>&lt;?php
$mcrypt = mcrypt_module_open(MCRYPT_DES, '', MCRYPT_MODE_CBC, '');
mcrypt_generic_init($mcrypt, '@@@@@@@@', 'xxxxxxxx'); 
echo bin2hex(mcrypt_generic($mcrypt, 'dddddddd'));
echo "\r\n"; 
echo bin2hex(mcrypt_generic($mcrypt, 'dddddddd'));
</code></pre>

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .