fix quoted-printable (_ means space only in rfc2047)
This commit is contained in:
parent
abb0a67b83
commit
6a8add52d3
2 changed files with 13 additions and 5 deletions
|
|
@ -31,6 +31,7 @@ enum
|
||||||
{
|
{
|
||||||
NoEncoding,
|
NoEncoding,
|
||||||
QuotedPrintable,
|
QuotedPrintable,
|
||||||
|
QuotedPrintableU,
|
||||||
Base64,
|
Base64,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ unhex(char *s)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
decqp(uchar *out, int lim, char *in, int n)
|
_decqp(uchar *out, int lim, char *in, int n, int underscores)
|
||||||
{
|
{
|
||||||
char *p, *ep;
|
char *p, *ep;
|
||||||
uchar *eout, *out0;
|
uchar *eout, *out0;
|
||||||
|
|
@ -29,7 +29,7 @@ decqp(uchar *out, int lim, char *in, int n)
|
||||||
out0 = out;
|
out0 = out;
|
||||||
eout = out+lim;
|
eout = out+lim;
|
||||||
for(p=in, ep=in+n; p<ep && out<eout; ){
|
for(p=in, ep=in+n; p<ep && out<eout; ){
|
||||||
if(*p == '_'){
|
if(underscores && *p == '_'){
|
||||||
*out++ = ' ';
|
*out++ = ' ';
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
|
|
@ -50,6 +50,12 @@ decqp(uchar *out, int lim, char *in, int n)
|
||||||
return out-out0;
|
return out-out0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
decqp(uchar *out, int lim, char *in, int n)
|
||||||
|
{
|
||||||
|
return _decqp(out, lim, in, n, 0);
|
||||||
|
}
|
||||||
|
|
||||||
char*
|
char*
|
||||||
decode(int kind, char *s, int *len)
|
decode(int kind, char *s, int *len)
|
||||||
{
|
{
|
||||||
|
|
@ -59,10 +65,11 @@ decode(int kind, char *s, int *len)
|
||||||
if(s == nil)
|
if(s == nil)
|
||||||
return s;
|
return s;
|
||||||
switch(kind){
|
switch(kind){
|
||||||
case QuotedPrintable:
|
case QuotedPrintable
|
||||||
|
case QuotedPrintableU:
|
||||||
l = strlen(s)+1;
|
l = strlen(s)+1;
|
||||||
t = emalloc(l);
|
t = emalloc(l);
|
||||||
l = decqp((uchar*)t, l, s, l-1);
|
l = decqp((uchar*)t, l, s, l-1, kind==QuotedPrintableU);
|
||||||
*len = l;
|
*len = l;
|
||||||
t[l] = 0;
|
t[l] = 0;
|
||||||
return t;
|
return t;
|
||||||
|
|
@ -202,7 +209,7 @@ unrfc2047(char *s)
|
||||||
case 'q':
|
case 'q':
|
||||||
case 'Q':
|
case 'Q':
|
||||||
*u = 0;
|
*u = 0;
|
||||||
v = decode(QuotedPrintable, t, &len);
|
v = decode(QuotedPrintableU, t, &len);
|
||||||
break;
|
break;
|
||||||
case 'b':
|
case 'b':
|
||||||
case 'B':
|
case 'B':
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue