diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-08-29 14:25:23 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-08-29 14:25:23 +0000 |
commit | d2da9597c3b9f2dded80f53c16f4bf2c630e0ffe (patch) | |
tree | 0f4623c73532c50b878bd00b9c9711c75ac9b4a3 /file.c | |
parent | 8ffeda041b92f1dbdc05d9356e05d9f624922ef3 (diff) |
* file.c (rb_get_path_check): clarify error message for
ASCII-incompatible path name.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29139 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'file.c')
-rw-r--r-- | file.c | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -148,6 +148,7 @@ rb_get_path_check(VALUE obj, int level) { VALUE tmp; ID to_path; + rb_encoding *enc; if (insecure_obj_p(obj, level)) { rb_insecure_operation(); @@ -161,11 +162,15 @@ rb_get_path_check(VALUE obj, int level) StringValue(tmp); tmp = file_path_convert(tmp); - StringValueCStr(tmp); if (obj != tmp && insecure_obj_p(tmp, level)) { rb_insecure_operation(); } - rb_enc_check(tmp, rb_enc_from_encoding(rb_usascii_encoding())); + enc = rb_enc_get(tmp); + if (!rb_enc_asciicompat(enc)) { + tmp = rb_str_inspect(tmp); + rb_raise(rb_eEncCompatError, "path name must be ASCII-compatible (%s): %s", + rb_enc_name(enc), RSTRING_PTR(tmp)); + } return rb_str_new4(tmp); } |