Fix #88
Apparently if a multipart field contains multiple dashes, it will be read in multiple chunks and these chunks should be concatenated in order to read the entire field correctly.
This commit is contained in:
parent
c6e5c6f018
commit
7522d41919
1 changed files with 6 additions and 2 deletions
|
@ -118,14 +118,16 @@ pub async fn create(
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
"content" => {
|
"content" => {
|
||||||
|
let mut content = String::from("");
|
||||||
while let Some(chunk) = field.try_next().await? {
|
while let Some(chunk) = field.try_next().await? {
|
||||||
new_pasta.content = std::str::from_utf8(&chunk).unwrap().to_string();
|
content.push_str(std::str::from_utf8(&chunk).unwrap().to_string().as_str());
|
||||||
new_pasta.pasta_type = if is_valid_url(new_pasta.content.as_str()) {
|
new_pasta.pasta_type = if is_valid_url(new_pasta.content.as_str()) {
|
||||||
String::from("url")
|
String::from("url")
|
||||||
} else {
|
} else {
|
||||||
String::from("text")
|
String::from("text")
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
new_pasta.content = content;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
"syntax-highlight" => {
|
"syntax-highlight" => {
|
||||||
|
@ -179,7 +181,9 @@ pub async fn create(
|
||||||
new_pasta.file = Some(file);
|
new_pasta.file = Some(file);
|
||||||
new_pasta.pasta_type = String::from("text");
|
new_pasta.pasta_type = String::from("text");
|
||||||
}
|
}
|
||||||
_ => {}
|
field => {
|
||||||
|
log::error!("Unexpected multipart field: {}", field);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue