Re: [PATCH] mailinfo: unescape quoted-pair in header fields

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jeff King <peff@xxxxxxxx> writes:

> So if that's the case, do we actually need to care if we see any
> parenthesized comments? I think we should just leave comments in place
> either way, so syntactically they are only interesting insofar as we
> replace quoted pairs or not.
>
> IOW, I wonder if:
>
>   while ((c = *in++)) {
> 	switch (c) {
> 	case '\\':
> 		if (!*in)
> 			return 0; /* ignore trailing backslash */
> 		/* quoted pair */
> 		strbuf_addch(out, *in++);
> 		break;
> 	case '"':
> 		/*
> 		 * This may be starting or ending a quoted section,
> 		 * but we do not care whether we are in such a section.
> 		 * We _do_ need to remove the quotes, though, as they
> 		 * are syntactic.
> 		 */
> 		break;
> 	default:
> 		/*
> 		 * Anything else is a normal character we keep. These
> 		 * _might_ be violating the RFC if they are magic
> 		 * characters outside of a quoted section, but we'd
> 		 * rather be liberal and pass them through.
> 		 */
> 		strbuf_addch(out, c);
> 		break;
> 	}
>   }
>
> would work. I certainly do not mind following the RFC more closely, but
> AFAICT the very simple code above gives a pretty forgiving outcome.

The simplicity of the code does look attractive to me.  I do not
offhand see an obvious case/flaw that this simplified rule would
mangle a valid human-readable part.




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]