@,;:\\\"/[]?="; $result = ''; if ( $input[0] === '"' ) { $length = strlen( $input ); for ( $i = 1; $i < $length; $i++ ) { $char = $input[$i]; if ( $char === '\\' && $i < $length - 1 ) { $result .= $input[++$i]; } elseif ( $char === '"' ) { if ( $i !== $length - 1 ) { throw new MultipartError( "Invalid quoted string" ); } break; } else { $result .= $char; } } } else { $length = strlen( $input ); for ( $i = 0; $i < $length; $i++ ) { $char = $input[$i]; $ord = ord( $char ); if ( strpos( $tspecials, $char ) !== false || $char === ' ' || $char === "\x7f" || $ord < 32 ) { throw new MultipartError( "Invalid unquoted string" ); } $result .= $char; } } return $result; } }