File tree Expand file tree Collapse file tree 1 file changed +20
-33
lines changed Expand file tree Collapse file tree 1 file changed +20
-33
lines changed Original file line number Diff line number Diff line change @@ -695,42 +695,29 @@ static int multipart_boundary_characters_valid(char *boundary) {
695
695
696
696
if (p == NULL ) return -1 ;
697
697
698
- while ((c = * p ) != '\0' ) {
699
- /* Control characters and space not allowed. */
700
- if (c < 32 ) {
698
+ while ((c = * p ) != '\0' ) {
699
+ // Check against allowed list defined in RFC2046 page 21
700
+ if (!(
701
+ ('0' <= c && c <= '9' )
702
+ || ('A' <= c && c <= 'Z' )
703
+ || ('a' <= c && c <= 'z' )
704
+ || (c == ' ' && * (p + 1 ) != '\0' ) // space allowed, but not as last character
705
+ || c == '\''
706
+ || c == '('
707
+ || c == ')'
708
+ || c == '+'
709
+ || c == '_'
710
+ || c == ','
711
+ || c == '-'
712
+ || c == '.'
713
+ || c == '/'
714
+ || c == ':'
715
+ || c == '='
716
+ || c == '?'
717
+ )) {
701
718
return 0 ;
702
719
}
703
720
704
- /* Non-ASCII characters not allowed. */
705
- if (c > 126 ) {
706
- return 0 ;
707
- }
708
-
709
- switch (c ) {
710
- /* Special characters not allowed. */
711
- case '(' :
712
- case ')' :
713
- case '<' :
714
- case '>' :
715
- case '@' :
716
- case ',' :
717
- case ';' :
718
- case ':' :
719
- case '\\' :
720
- case '"' :
721
- case '/' :
722
- case '[' :
723
- case ']' :
724
- case '?' :
725
- case '=' :
726
- return 0 ;
727
- break ;
728
-
729
- default :
730
- /* Do nothing. */
731
- break ;
732
- }
733
-
734
721
p ++ ;
735
722
}
736
723
You can’t perform that action at this time.
0 commit comments