Quantcast
Channel: Active questions tagged code-formatting - Meta Stack Overflow
Viewing all articles
Browse latest Browse all 182

Should there be a warning for code containing bidirectional Unicode text?

$
0
0

Articles on the misuse of bidirectional text have been making the rounds recently. Put simply, this abuses the concept of bidirectional Unicode text to compile something different from what it appears to be to a human.

For instance, the following little snippet:

#include <stdio.h>int main() {    int admin = 0;    /*‮ } ⁦if (admin)⁩⁦ Verify admin: */        printf("You're an admin.\n");    /* End check ‮ { ⁦*/    return 0;}

When compiled and run this will show "You're an admin" despite looking like it shouldn't because of the if check. While there is a hint if you look closely at the syntax highlighting here, or if you drag a browser's highlighter over the text it might act odd, it's easy to miss.

I very much doubt this is a concern right now, but should Stack Overflow follow GitHub's actions and warn if a code snippet contains such control characters to prevent any possibilities of unexpected side effects of copy-pasting code?


Viewing all articles
Browse latest Browse all 182


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>