@@ -9658,7 +9658,8 @@ escape_read(pm_parser_t *parser, pm_buffer_t *buffer, pm_buffer_t *regular_expre
9658
9658
pm_parser_err(parser, unicode_start, unicode_start + hexadecimal_length, PM_ERR_ESCAPE_INVALID_UNICODE_LONG);
9659
9659
} else if (hexadecimal_length == 0) {
9660
9660
// there are not hexadecimal characters
9661
- pm_parser_err(parser, unicode_start, unicode_start + hexadecimal_length, PM_ERR_ESCAPE_INVALID_UNICODE);
9661
+ pm_parser_err(parser, parser->current.end, parser->current.end, PM_ERR_ESCAPE_INVALID_UNICODE);
9662
+ pm_parser_err(parser, parser->current.end, parser->current.end, PM_ERR_ESCAPE_INVALID_UNICODE_TERM);
9662
9663
return;
9663
9664
}
9664
9665
@@ -9707,10 +9708,6 @@ escape_read(pm_parser_t *parser, pm_buffer_t *buffer, pm_buffer_t *regular_expre
9707
9708
}
9708
9709
}
9709
9710
9710
- if (flags & (PM_ESCAPE_FLAG_CONTROL | PM_ESCAPE_FLAG_META)) {
9711
- pm_parser_err(parser, start, parser->current.end, PM_ERR_INVALID_ESCAPE_CHARACTER);
9712
- }
9713
-
9714
9711
return;
9715
9712
}
9716
9713
case 'c': {
@@ -9733,6 +9730,12 @@ escape_read(pm_parser_t *parser, pm_buffer_t *buffer, pm_buffer_t *regular_expre
9733
9730
return;
9734
9731
}
9735
9732
parser->current.end++;
9733
+
9734
+ if (match(parser, 'u') || match(parser, 'U')) {
9735
+ pm_parser_err(parser, parser->current.start, parser->current.end, PM_ERR_INVALID_ESCAPE_CHARACTER);
9736
+ return;
9737
+ }
9738
+
9736
9739
escape_read(parser, buffer, regular_expression_buffer, flags | PM_ESCAPE_FLAG_CONTROL);
9737
9740
return;
9738
9741
case ' ':
@@ -9760,7 +9763,8 @@ escape_read(pm_parser_t *parser, pm_buffer_t *buffer, pm_buffer_t *regular_expre
9760
9763
case 'C': {
9761
9764
parser->current.end++;
9762
9765
if (peek(parser) != '-') {
9763
- pm_parser_err_current(parser, PM_ERR_ESCAPE_INVALID_CONTROL);
9766
+ size_t width = parser->encoding->char_width(parser->current.end, parser->end - parser->current.end);
9767
+ pm_parser_err(parser, parser->current.start, parser->current.end + width, PM_ERR_ESCAPE_INVALID_CONTROL);
9764
9768
return;
9765
9769
}
9766
9770
@@ -9783,6 +9787,12 @@ escape_read(pm_parser_t *parser, pm_buffer_t *buffer, pm_buffer_t *regular_expre
9783
9787
return;
9784
9788
}
9785
9789
parser->current.end++;
9790
+
9791
+ if (match(parser, 'u') || match(parser, 'U')) {
9792
+ pm_parser_err(parser, parser->current.start, parser->current.end, PM_ERR_INVALID_ESCAPE_CHARACTER);
9793
+ return;
9794
+ }
9795
+
9786
9796
escape_read(parser, buffer, regular_expression_buffer, flags | PM_ESCAPE_FLAG_CONTROL);
9787
9797
return;
9788
9798
case ' ':
@@ -9797,7 +9807,8 @@ escape_read(pm_parser_t *parser, pm_buffer_t *buffer, pm_buffer_t *regular_expre
9797
9807
return;
9798
9808
default: {
9799
9809
if (!char_is_ascii_printable(peeked)) {
9800
- pm_parser_err_current(parser, PM_ERR_ESCAPE_INVALID_CONTROL);
9810
+ size_t width = parser->encoding->char_width(parser->current.end, parser->end - parser->current.end);
9811
+ pm_parser_err(parser, parser->current.start, parser->current.end + width, PM_ERR_ESCAPE_INVALID_CONTROL);
9801
9812
return;
9802
9813
}
9803
9814
@@ -9810,7 +9821,8 @@ escape_read(pm_parser_t *parser, pm_buffer_t *buffer, pm_buffer_t *regular_expre
9810
9821
case 'M': {
9811
9822
parser->current.end++;
9812
9823
if (peek(parser) != '-') {
9813
- pm_parser_err_current(parser, PM_ERR_ESCAPE_INVALID_META);
9824
+ size_t width = parser->encoding->char_width(parser->current.end, parser->end - parser->current.end);
9825
+ pm_parser_err(parser, parser->current.start, parser->current.end + width, PM_ERR_ESCAPE_INVALID_META);
9814
9826
return;
9815
9827
}
9816
9828
@@ -9828,6 +9840,12 @@ escape_read(pm_parser_t *parser, pm_buffer_t *buffer, pm_buffer_t *regular_expre
9828
9840
return;
9829
9841
}
9830
9842
parser->current.end++;
9843
+
9844
+ if (match(parser, 'u') || match(parser, 'U')) {
9845
+ pm_parser_err(parser, parser->current.start, parser->current.end, PM_ERR_INVALID_ESCAPE_CHARACTER);
9846
+ return;
9847
+ }
9848
+
9831
9849
escape_read(parser, buffer, regular_expression_buffer, flags | PM_ESCAPE_FLAG_META);
9832
9850
return;
9833
9851
case ' ':
@@ -9842,7 +9860,8 @@ escape_read(pm_parser_t *parser, pm_buffer_t *buffer, pm_buffer_t *regular_expre
9842
9860
return;
9843
9861
default:
9844
9862
if (!char_is_ascii_printable(peeked)) {
9845
- pm_parser_err_current(parser, PM_ERR_ESCAPE_INVALID_META);
9863
+ size_t width = parser->encoding->char_width(parser->current.end, parser->end - parser->current.end);
9864
+ pm_parser_err(parser, parser->current.start, parser->current.end + width, PM_ERR_ESCAPE_INVALID_META);
9846
9865
return;
9847
9866
}
9848
9867
0 commit comments