File tree Expand file tree Collapse file tree 1 file changed +5
-7
lines changed Expand file tree Collapse file tree 1 file changed +5
-7
lines changed Original file line number Diff line number Diff line change @@ -64,7 +64,7 @@ pub fn parse_with_encoding<'a>(input: &'a [u8],
64
64
for sequence in input. split ( |& b| b == b'&' ) {
65
65
// No '+' in "_charset_" to replace with ' '.
66
66
if sequence. starts_with ( b"_charset_=" ) {
67
- let value = unsafe { & sequence. get_unchecked ( b"_charset_=" . len ( ) ..) } ;
67
+ let value = & sequence[ b"_charset_=" . len ( ) ..] ;
68
68
// Skip replacing '+' with ' ' in value since no encoding label contains either:
69
69
// https://encoding.spec.whatwg.org/#names-and-labels
70
70
if let Some ( e) = EncodingOverride :: lookup ( value) {
@@ -126,12 +126,10 @@ fn replace_plus(input: &[u8]) -> Cow<[u8]> {
126
126
None => Cow :: Borrowed ( input) ,
127
127
Some ( first_position) => {
128
128
let mut replaced = input. to_owned ( ) ;
129
- unsafe {
130
- * replaced. get_unchecked_mut ( first_position) = b' ' ;
131
- for byte in replaced. get_unchecked_mut ( first_position + 1 ..) {
132
- if * byte == b'+' {
133
- * byte = b' ' ;
134
- }
129
+ replaced[ first_position] = b' ' ;
130
+ for byte in & mut replaced[ first_position + 1 ..] {
131
+ if * byte == b'+' {
132
+ * byte = b' ' ;
135
133
}
136
134
}
137
135
Cow :: Owned ( replaced)
You can’t perform that action at this time.
0 commit comments