|
|
@@ -214,7 +214,14 @@ impl<'a, T: Target> Serializer<'a, T> {
|
|
|
/// If that suffix is non-empty,
|
|
|
/// its content is assumed to already be in `application/x-www-form-urlencoded` syntax.
|
|
|
pub fn for_suffix(mut target: T, start_position: usize) -> Self {
|
|
|
- &target.as_mut_string()[start_position..]; // Panic if out of bounds
|
|
|
+ if target.as_mut_string().len() < start_position {
|
|
|
+ panic!(
|
|
|
+ "invalid length {} for target of length {}",
|
|
|
+ start_position,
|
|
|
+ target.as_mut_string().len()
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
Serializer {
|
|
|
target: Some(target),
|
|
|
start_position,
|
|
|
@@ -327,5 +334,5 @@ fn append_pair(
|
|
|
}
|
|
|
|
|
|
fn append_encoded(s: &str, string: &mut String, encoding: EncodingOverride) {
|
|
|
- string.extend(byte_serialize(&query_encoding::encode(encoding, s.into())))
|
|
|
+ string.extend(byte_serialize(&query_encoding::encode(encoding, s)))
|
|
|
}
|