You've already forked AstralRinth
forked from didirus/AstralRinth
Fix pack URL validation, Version file update route, and spaces in file download URLs (#275)
This commit is contained in:
@@ -633,7 +633,9 @@ pub async fn upload_file(
|
||||
content_type,
|
||||
&format!(
|
||||
"data/{}/versions/{}/{}",
|
||||
project_id, version_number, file_name
|
||||
project_id,
|
||||
version_number,
|
||||
urlencoding::encode(&file_name)
|
||||
),
|
||||
data.freeze(),
|
||||
)
|
||||
|
||||
@@ -306,7 +306,6 @@ pub async fn delete_file(
|
||||
|
||||
#[derive(Deserialize)]
|
||||
pub struct UpdateData {
|
||||
pub hash: (String, String),
|
||||
pub loaders: Vec<Loader>,
|
||||
pub game_versions: Vec<GameVersion>,
|
||||
}
|
||||
|
||||
@@ -34,12 +34,17 @@ pub struct PackFile<'a> {
|
||||
|
||||
fn validate_download_url(values: &Vec<&str>) -> Result<(), validator::ValidationError> {
|
||||
for value in values {
|
||||
let url = url::Url::parse(value)
|
||||
.ok()
|
||||
.ok_or_else(|| validator::ValidationError::new("invalid URL"))?;
|
||||
|
||||
if &url.as_str() != value {
|
||||
return Err(validator::ValidationError::new("invalid URL"));
|
||||
}
|
||||
|
||||
let domains = parse_strings_from_var("WHITELISTED_MODPACK_DOMAINS").unwrap_or_default();
|
||||
if !domains.contains(
|
||||
&url::Url::parse(value)
|
||||
.ok()
|
||||
.ok_or_else(|| validator::ValidationError::new("invalid URL"))?
|
||||
.domain()
|
||||
&url.domain()
|
||||
.ok_or_else(|| validator::ValidationError::new("invalid URL"))?
|
||||
.to_string(),
|
||||
) {
|
||||
|
||||
Reference in New Issue
Block a user