rouge icon indicating copy to clipboard operation
rouge copied to clipboard

the PHP lexer does not properly handle namespace separators in qualified names

Open stof opened this issue 4 years ago • 6 comments

Name of the lexer PHP

Code sample

<?php

use ScssPhp\ScssPhp\Compiler;

try {
    $compiler = new Compiler();

    echo $compiler->compileString($content)->getCss();
} catch (\Exception $e) {
    echo '';
    syslog(LOG_ERR, 'scssphp: Unable to compile content');
}

I could not provide this on http://rouge.jneen.net/ because I got 503 errors when trying to use it.

Additional context the \ in catch(\Exception $e) gets highlighted as an error, while it is not an error

stof avatar Jun 25 '21 13:06 stof

/cc @pyrmont as I saw you rewrote the PHP lexer

stof avatar Jun 25 '21 14:06 stof

@stof I'm not working on this project any more but in my quick tests, it looks like there's a problem with the lexing of the ( after compileString. Not sure if fixing that will fix everything else.

pyrmont avatar Jun 26 '21 00:06 pyrmont

@pyrmont which kind of problem ?

stof avatar Jun 28 '21 08:06 stof

For reference, the live version of that code snippet is at https://scssphp.github.io/scssphp/docs/#security-considerations This is rendered using github pages, which uses rouge.

stof avatar Jun 28 '21 08:06 stof

@stof If you paste your example up to the ( in the dingus, it updates the right hand side but as soon as you have the ( then it stops updating. So I assume there something breaking there.

pyrmont avatar Jun 28 '21 08:06 pyrmont

Hi,

from my own testing, it seems that absolute name classes (which starts with a \) are not correctly handled: id_with_ns should be defined more like /#{id}(?:\\#{id})*|\\#{id}(?:\\#{id})*/ because currently, it does not allow this \ character at its beginning.

julp avatar Oct 25 '21 20:10 julp

This issue has been automatically marked as stale because it has not had any activity for more than a year. It will be closed if no additional activity occurs within the next 14 days. If you would like this issue to remain open, please reply and let us know if the issue is still reproducible.

stale[bot] avatar Nov 02 '22 04:11 stale[bot]