Project

General

Profile

Bug #13955

NKF.nkf のオプション文字列が SHARABLE_MIDDLE_SUBSTRING=1 を考慮していない

Added by tommy (Masahiro Tomita) over 1 year ago. Updated over 1 year ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
[ruby-dev:50269]

Description

SHARABLE_MIDDLE_SUBSTRING=1 でコンパイルしたRubyで、NKF.nkf のオプション文字列が正しく扱われません。

% ruby -rnkf -e 'opt="--ic=UTF-8 --oc=EUC-JISX0213 -w"[0,28]; p opt; p NKF.nkf(opt, "あ").encoding'
"--ic=UTF-8 --oc=EUC-JISX0213"
#<Encoding:UTF-8>

次のパッチで直ると思います。

diff --git a/ext/nkf/nkf.c b/ext/nkf/nkf.c
index 9613a925ce..df32e9cf0b 100644
--- a/ext/nkf/nkf.c
+++ b/ext/nkf/nkf.c
@@ -137,7 +137,7 @@ rb_nkf_convert(VALUE obj, VALUE opt, VALUE src)
 {
     VALUE tmp;
     reinit();
-    StringValue(opt);
+    StringValueCStr(opt);
     nkf_split_options(RSTRING_PTR(opt));
     if (!output_encoding) rb_raise(rb_eArgError, "no output encoding given");

適用後

% ruby -rnkf -e 'opt="--ic=UTF-8 --oc=EUC-JISX0213 -w"[0,28]; p opt; p NKF.nkf(opt, "あ").encoding'
"--ic=UTF-8 --oc=EUC-JISX0213"
#<Encoding:EUC-JIS-2004>

Associated revisions

Revision 60071
Added by nobu (Nobuyoshi Nakada) over 1 year ago

ext: check if null byte is contained

[ruby-dev:50267] [Bug #13953]

Revision 76940d8a
Added by nagachika (Tomoyuki Chikanaga) over 1 year ago

merge revision(s) 60071: [Backport #13953] [Backport #13954] [Backport #13955] [Backport #13957]

    ext: check if null byte is contained

    [ruby-dev:50267] [Bug #13953]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_4@61456 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 61456
Added by nagachika (Tomoyuki Chikanaga) over 1 year ago

merge revision(s) 60071: [Backport #13953] [Backport #13954] [Backport #13955] [Backport #13957]

ext: check if null byte is contained

[ruby-dev:50267] [Bug #13953]

Revision 3d6510c5
Added by usa (Usaku NAKAMURA) over 1 year ago

merge revision(s) 60071: [Backport #13953] [Backport #13954] [Backport #13955] [Backport #13957]

    ext: check if null byte is contained

    [ruby-dev:50267] [Bug #13953]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_3@62140 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 62140
Added by usa (Usaku NAKAMURA) over 1 year ago

merge revision(s) 60071: [Backport #13953] [Backport #13954] [Backport #13955] [Backport #13957]

ext: check if null byte is contained

[ruby-dev:50267] [Bug #13953]

History

#1

Updated by nobu (Nobuyoshi Nakada) over 1 year ago

  • Backport changed from 2.3: UNKNOWN, 2.4: UNKNOWN to 2.3: REQUIRED, 2.4: REQUIRED
  • Status changed from Open to Closed

Updated by nagachika (Tomoyuki Chikanaga) over 1 year ago

  • Backport changed from 2.3: REQUIRED, 2.4: REQUIRED to 2.3: REQUIRED, 2.4: DONE

ruby_2_4 r61456 merged revision(s) 60071.

Updated by usa (Usaku NAKAMURA) over 1 year ago

  • Backport changed from 2.3: REQUIRED, 2.4: DONE to 2.3: DONE, 2.4: DONE

ruby_2_3 r62140 merged revision(s) 60071.

Also available in: Atom PDF