|
a/src/internfile/mh_exec.cpp |
|
b/src/internfile/mh_exec.cpp |
|
... |
|
... |
151 |
// If output is text/plain (not text/html), we may have to convert
|
151 |
// If output is text/plain (not text/html), we may have to convert
|
152 |
// it to utf-8, because this is the last point where it can be done.
|
152 |
// it to utf-8, because this is the last point where it can be done.
|
153 |
// cfgFilterOutputCharset comes from the mimeconf filter definition line
|
153 |
// cfgFilterOutputCharset comes from the mimeconf filter definition line
|
154 |
string charset = cfgFilterOutputCharset.empty() ? "utf-8" :
|
154 |
string charset = cfgFilterOutputCharset.empty() ? "utf-8" :
|
155 |
cfgFilterOutputCharset;
|
155 |
cfgFilterOutputCharset;
|
|
|
156 |
bool trustcharset = true;
|
156 |
if (!stringlowercmp("default", charset)) {
|
157 |
if (!stringlowercmp("default", charset)) {
|
157 |
charset = m_dfltInputCharset;
|
158 |
charset = m_dfltInputCharset;
|
|
|
159 |
trustcharset = false;
|
158 |
}
|
160 |
}
|
159 |
string mt = cfgFilterOutputMtype.empty() ? "text/html" :
|
161 |
string mt = cfgFilterOutputMtype.empty() ? "text/html" :
|
160 |
cfgFilterOutputMtype;
|
162 |
cfgFilterOutputMtype;
|
161 |
if (!mt.compare(cstr_textplain) && stringlowercmp("utf-8", charset)) {
|
163 |
|
|
|
164 |
// If this is text/plain and not utf-8 or untrusted, transcode to utf-8.
|
|
|
165 |
if (!mt.compare(cstr_textplain) &&
|
|
|
166 |
(!trustcharset || stringlowercmp("utf-8", charset))) {
|
162 |
string transcoded;
|
167 |
string transcoded;
|
163 |
int ecnt;
|
168 |
int ecnt;
|
164 |
if (!transcode(output, transcoded, charset, "UTF-8", &ecnt)) {
|
169 |
if (!transcode(output, transcoded, charset, "UTF-8", &ecnt)) {
|
165 |
LOGERR(("mh_exec: transcode failed from [%s] to UTF-8\n",
|
170 |
LOGERR(("mh_exec: transcode failed from [%s] to UTF-8\n",
|
166 |
charset.c_str()));
|
171 |
charset.c_str()));
|
|
|
172 |
// Erase text in this case: it's garbage
|
|
|
173 |
output.clear();
|
167 |
} else {
|
174 |
} else {
|
168 |
if (ecnt) {
|
175 |
if (ecnt) {
|
169 |
LOGDEB(("mh_exec: %d transcoding errors from [%s] to UTF-8\n",
|
176 |
LOGDEB(("mh_exec: %d transcoding errors from [%s] to UTF-8\n",
|
170 |
ecnt, charset.c_str()));
|
177 |
ecnt, charset.c_str()));
|
171 |
}
|
178 |
}
|