atom/language-php

I was just testing other languages and it looks like C++ highlighting on a PHP file does not have syntax highlighting break due to SQL.

Closed this issue · 2 comments

I was just testing other languages and it looks like C++ highlighting on a PHP file does not have syntax highlighting break due to SQL.

So I guess this is a fix but this is kind of silly to be the solution.

Originally posted by @samifouad in #333 (comment)

Is it possible to compare whatever C++ is doing and apply it to PHP with some modified colours? Or simply revert to using the C++ highlighting for PHP by default?

The bug is two years old now, so it would be great that any sort of fix is applied here.

@samifouad Before going technical: You can avoid all sql highlighting issues using prepared statements or simple variables ("SELECT `{$column}`...") instead of concatenation.

In my case c++ and js isn't any better in highlighting php files. In fact I didn't have sql colors at all. Can you provide sample code and tell which editor are you using?

However I believe that other languages don't have such problems. Everything is broken because of "feature" where concatenation doesn't stop sql highlighting e.g. "SELECT "." * FROM table", combined with fact that strings in php can take multiple lines and that textmate grammar can parse one line at the time. Other languages are using tree-sitter (which works a bit differently) or have single-lined strings.

I'm currently working how this could be fixed, but it's complicated matter and probably will kill some of these "features". Also vscode and atom are using different sql injections, which further complicates fixes.