[Bug #20280] Check by rb_parser_enc_str_coderange
Co-authored-by: Yuichiro Kaneko <spiketeika@gmail.com>
This commit is contained in:
parent
fcc55dc226
commit
b1d70e4264
@ -46,7 +46,6 @@ int rb_enc_str_coderange_scan(VALUE str, rb_encoding *enc);
|
|||||||
int rb_ascii8bit_appendable_encoding_index(rb_encoding *enc, unsigned int code);
|
int rb_ascii8bit_appendable_encoding_index(rb_encoding *enc, unsigned int code);
|
||||||
VALUE rb_str_include(VALUE str, VALUE arg);
|
VALUE rb_str_include(VALUE str, VALUE arg);
|
||||||
VALUE rb_str_byte_substr(VALUE str, VALUE beg, VALUE len);
|
VALUE rb_str_byte_substr(VALUE str, VALUE beg, VALUE len);
|
||||||
VALUE rb_str_valid_encoding_p(VALUE str);
|
|
||||||
|
|
||||||
static inline bool STR_EMBED_P(VALUE str);
|
static inline bool STR_EMBED_P(VALUE str);
|
||||||
static inline bool STR_SHARED_P(VALUE str);
|
static inline bool STR_SHARED_P(VALUE str);
|
||||||
|
8
parse.y
8
parse.y
@ -13730,11 +13730,15 @@ new_defined(struct parser_params *p, NODE *expr, const YYLTYPE *loc)
|
|||||||
static NODE*
|
static NODE*
|
||||||
str_to_sym_node(struct parser_params *p, NODE *node, const YYLTYPE *loc)
|
str_to_sym_node(struct parser_params *p, NODE *node, const YYLTYPE *loc)
|
||||||
{
|
{
|
||||||
VALUE lit = rb_node_str_string_val(node);
|
VALUE lit;
|
||||||
if (!rb_str_valid_encoding_p(lit)) {
|
rb_parser_string_t *str = RNODE_STR(node)->string;
|
||||||
|
if (rb_parser_enc_str_coderange(p, str) == RB_PARSER_ENC_CODERANGE_BROKEN) {
|
||||||
yyerror1(loc, "invalid symbol");
|
yyerror1(loc, "invalid symbol");
|
||||||
lit = STR_NEW0();
|
lit = STR_NEW0();
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
lit = rb_str_new_parser_string(str);
|
||||||
|
}
|
||||||
return NEW_SYM(lit, loc);
|
return NEW_SYM(lit, loc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -551,7 +551,6 @@ static const rb_parser_config_t rb_global_parser_config = {
|
|||||||
.id2str = rb_id2str,
|
.id2str = rb_id2str,
|
||||||
.id2sym = rb_id2sym,
|
.id2sym = rb_id2sym,
|
||||||
.sym2id = rb_sym2id,
|
.sym2id = rb_sym2id,
|
||||||
.str_valid_encoding_p = rb_str_valid_encoding_p,
|
|
||||||
|
|
||||||
.str_catf = rb_str_catf,
|
.str_catf = rb_str_catf,
|
||||||
.str_cat_cstr = rb_str_cat_cstr,
|
.str_cat_cstr = rb_str_cat_cstr,
|
||||||
|
@ -1277,7 +1277,6 @@ typedef struct rb_parser_config_struct {
|
|||||||
VALUE (*id2str)(ID id);
|
VALUE (*id2str)(ID id);
|
||||||
VALUE (*id2sym)(ID x);
|
VALUE (*id2sym)(ID x);
|
||||||
ID (*sym2id)(VALUE sym);
|
ID (*sym2id)(VALUE sym);
|
||||||
VALUE (*str_valid_encoding_p)(VALUE str);
|
|
||||||
|
|
||||||
/* String */
|
/* String */
|
||||||
RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 2, 3)
|
RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 2, 3)
|
||||||
|
2
string.c
2
string.c
@ -11030,7 +11030,7 @@ rb_str_b(VALUE str)
|
|||||||
* "\x80".force_encoding("UTF-8").valid_encoding? # => false
|
* "\x80".force_encoding("UTF-8").valid_encoding? # => false
|
||||||
*/
|
*/
|
||||||
|
|
||||||
VALUE
|
static VALUE
|
||||||
rb_str_valid_encoding_p(VALUE str)
|
rb_str_valid_encoding_p(VALUE str)
|
||||||
{
|
{
|
||||||
int cr = rb_enc_str_coderange(str);
|
int cr = rb_enc_str_coderange(str);
|
||||||
|
@ -173,7 +173,6 @@ struct rb_imemo_tmpbuf_struct {
|
|||||||
#define ID2SYM p->config->id2sym
|
#define ID2SYM p->config->id2sym
|
||||||
#undef SYM2ID
|
#undef SYM2ID
|
||||||
#define SYM2ID p->config->sym2id
|
#define SYM2ID p->config->sym2id
|
||||||
#define rb_str_valid_encoding_p p->config->str_valid_encoding_p
|
|
||||||
|
|
||||||
#define rb_str_catf p->config->str_catf
|
#define rb_str_catf p->config->str_catf
|
||||||
#undef rb_str_cat_cstr
|
#undef rb_str_cat_cstr
|
||||||
|
Loading…
x
Reference in New Issue
Block a user