[PRISM] Check length of line for shebang
This commit is contained in:
parent
91c6c2bdb5
commit
4c5a1dad0a
Notes:
git
2024-08-28 14:51:06 +00:00
@ -21961,10 +21961,10 @@ pm_parser_init(pm_parser_t *parser, const uint8_t *source, size_t size, const pm
|
|||||||
|
|
||||||
// If the first two bytes of the source are a shebang, then we'll indicate
|
// If the first two bytes of the source are a shebang, then we'll indicate
|
||||||
// that the encoding comment is at the end of the shebang.
|
// that the encoding comment is at the end of the shebang.
|
||||||
if (peek(parser) == '#' && peek_offset(parser, 1) == '!') {
|
const uint8_t *newline = next_newline(parser->start, parser->end - parser->start);
|
||||||
const uint8_t *newline = next_newline(parser->start, parser->end - parser->start);
|
size_t length = (size_t) ((newline != NULL ? newline : parser->end) - parser->start);
|
||||||
size_t length = (size_t) ((newline != NULL ? newline : parser->end) - parser->start);
|
|
||||||
|
|
||||||
|
if (length > 2 && parser->current.end[0] == '#' && parser->current.end[1] == '!') {
|
||||||
const char *engine;
|
const char *engine;
|
||||||
if ((engine = pm_strnstr((const char *) parser->start, "ruby", length)) != NULL) {
|
if ((engine = pm_strnstr((const char *) parser->start, "ruby", length)) != NULL) {
|
||||||
if (newline != NULL) {
|
if (newline != NULL) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user