Backport #8165 ยป 0001-load.c-fix-require-with-non-ascii-path.patch
internal.h | ||
---|---|---|
int rb_str_symname_p(VALUE);
|
||
VALUE rb_str_quote_unprintable(VALUE);
|
||
VALUE rb_id_quote_unprintable(ID);
|
||
VALUE rb_str_subseq_without_enc(VALUE, long, long);
|
||
#define QUOTE(str) rb_str_quote_unprintable(str)
|
||
#define QUOTE_ID(id) rb_id_quote_unprintable(id)
|
||
load.c | ||
---|---|---|
if (p < feature_str)
|
||
break;
|
||
/* Now *p == '/'. We reach this point for every '/' in `feature`. */
|
||
short_feature = rb_str_substr(feature, p + 1 - feature_str, feature_end - p - 1);
|
||
short_feature = rb_str_subseq_without_enc(feature, p + 1 - feature_str, feature_end - p - 1);
|
||
features_index_add_single(short_feature, offset);
|
||
if (ext) {
|
||
short_feature = rb_str_substr(feature, p + 1 - feature_str, ext - p - 1);
|
||
short_feature = rb_str_subseq_without_enc(feature, p + 1 - feature_str, ext - p - 1);
|
||
features_index_add_single(short_feature, offset);
|
||
}
|
||
}
|
||
features_index_add_single(feature, offset);
|
||
if (ext) {
|
||
short_feature = rb_str_substr(feature, 0, ext - feature_str);
|
||
short_feature = rb_str_subseq_without_enc(feature, 0, ext - feature_str);
|
||
features_index_add_single(short_feature, offset);
|
||
}
|
||
}
|
string.c | ||
---|---|---|
}
|
||
VALUE
|
||
rb_str_subseq(VALUE str, long beg, long len)
|
||
rb_str_subseq_without_enc(VALUE str, long beg, long len)
|
||
{
|
||
VALUE str2;
|
||
... | ... | |
RB_GC_GUARD(str);
|
||
}
|
||
rb_enc_cr_str_copy_for_substr(str2, str);
|
||
OBJ_INFECT(str2, str);
|
||
return str2;
|
||
}
|
||
VALUE
|
||
rb_str_subseq(VALUE str, long beg, long len)
|
||
{
|
||
VALUE str2 = rb_str_subseq_without_enc(str, beg, len);
|
||
rb_enc_cr_str_copy_for_substr(str2, str);
|
||
return str2;
|
||
}
|
||
static char *
|
||
rb_str_subpos(VALUE str, long beg, long *lenp)
|
||
{
|
test/ruby/test_require.rb | ||
---|---|---|
ensure
|
||
script.close(true) if script
|
||
end
|
||
def test_require_with_non_ascii_path
|
||
bug8165 = '[ruby-core:53733] [Bug #8165]'
|
||
Dir.mktmpdir {|tmp|
|
||
Dir.chdir(tmp) {
|
||
dir = "\u3042" * 5
|
||
Dir.mkdir(dir)
|
||
path = File.join(tmp, dir, 'foo.rb').force_encoding('UTF-8')
|
||
open(path, "w") {|f|
|
||
f.puts "p :ok"
|
||
}
|
||
assert_in_out_err([], <<-INPUT, %w(:ok), [], bug8165)
|
||
# coding: UTF-8
|
||
$:.replace([IO::NULL])
|
||
require '#{path}'
|
||
p :ng if require '#{path}'
|
||
INPUT
|
||
}
|
||
}
|
||
end
|
||
end
|