From 0be34e2a497ec376e3a96e95a2374abe3ad6a7c6 Mon Sep 17 00:00:00 2001 From: akr Date: Fri, 5 Sep 2008 22:27:46 +0000 Subject: * transcode.c (rb_econv_open): fail for ASCII incompatible with newline conversion. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19167 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- transcode.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'transcode.c') diff --git a/transcode.c b/transcode.c index 6496c75c76..3dbdb44d1c 100644 --- a/transcode.c +++ b/transcode.c @@ -913,6 +913,19 @@ rb_econv_open(const char *sname, const char *dname, int ecflags) } num_additional = 0; + + if (*sname && (!senc || !rb_enc_asciicompat(senc)) && + (ecflags & (ECONV_CRLF_NEWLINE_ENCODER|ECONV_CR_NEWLINE_ENCODER))) { + xfree(entries); + return NULL; + } + + if (*dname && (!denc || !rb_enc_asciicompat(denc)) && + (ecflags & (ECONV_UNIVERSAL_NEWLINE_DECODER))) { + xfree(entries); + return NULL; + } + if ((!*sname || (senc && rb_enc_asciicompat(senc))) && (ecflags & (ECONV_CRLF_NEWLINE_ENCODER|ECONV_CR_NEWLINE_ENCODER))) { const char *name = (ecflags & ECONV_CRLF_NEWLINE_ENCODER) ? "crlf_newline" : "cr_newline"; -- cgit v1.2.3