In an HTML form post what are valid characters for creating a multipart boundary?
2 Answers
According to RFC 2046, section 5.1.1:
boundary := 0*69<bchars> bcharsnospace
bchars := bcharsnospace / " "
bcharsnospace := DIGIT / ALPHA / "'" / "(" / ")" /
"+" / "_" / "," / "-" / "." /
"/" / ":" / "=" / "?"
So it can be between 1 and 70 characters long, consisting of alphanumeric, and the punctuation you see in the list. Spaces are allowed except at the end.

- 1,938
- 10
- 56
- 123

- 219,335
- 46
- 382
- 435
-
I just tested this and it looks like apache doesn't accept ",". – lajos Sep 29 '08 at 04:44
-
@Chris what's the "safe" characters to use? – Pacerier Jan 11 '12 at 02:01
-
2hmm so I can't draw scissors --8<--- cut here --8<-- – Jasen Aug 11 '14 at 21:48
There are no rules as of the content of the boundary but as it must not occur in any of the parts of your message content is usually a randomly generated sequence of numbers, letters or combination of both in order to guarantee uniqueness and differentiate from any possible dictionary words. So as you start your message each data type section is separated by “–” followed by the boundary sequence and the content type + encoding. After the last section “–” followed by the boundary followed by “–” is used to delimit the end of the message. The way multipart content works is by specifying a boundary in the “Content-type:” header of your email. The boundary is used to separate the different content types and looks something like this:
Content-type: multipart/mixed; boundary="fU3W4Vzr4G3D54f3"

- 16,560
- 3
- 22
- 19
-
2Oh, but there _are_ rules, even if most people never violate them. :-) – C. K. Young Sep 29 '08 at 04:04
-
Well, the rule is that it cannot occur within thing message you are submitting. I suppose it was worded wrong, but a down vote? pssh :P – camflan Sep 29 '08 at 04:15
-
@Pacerier There are rules, they are in RFC-2046, it you are writing emails you MUST follow the rules, if you are reading you SHOULD be more lenient. – Jasen Aug 11 '14 at 22:00