summaryrefslogtreecommitdiff
path: root/transcode.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-09-05 22:27:46 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-09-05 22:27:46 +0000
commit0be34e2a497ec376e3a96e95a2374abe3ad6a7c6 (patch)
treef1c4b83567fe7acfae9ca537c25dc4881cd8e268 /transcode.c
parentd4384f1230af19b065f62a33b27ac21143235304 (diff)
* 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
Diffstat (limited to 'transcode.c')
-rw-r--r--transcode.c13
1 files changed, 13 insertions, 0 deletions
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";