mirror of
https://github.com/modrinth/code.git
synced 2026-09-03 13:36:48 +00:00
Tighten URL slug validation (#6442)
* Tighten URL slug validation * slug sanitization in frontend
This commit is contained in:
@@ -184,14 +184,14 @@ pub async fn projects_list(
|
||||
|
||||
#[derive(Serialize, Deserialize, Validate, utoipa::ToSchema)]
|
||||
pub struct EditUser {
|
||||
#[validate(length(min = 1, max = 39), regex(path = *crate::util::validate::RE_USERNAME))]
|
||||
#[validate(length(min = 1, max = 39), regex(path = *crate::util::validate::RE_URL_SAFE))]
|
||||
pub username: Option<String>,
|
||||
#[serde(
|
||||
default,
|
||||
skip_serializing_if = "Option::is_none",
|
||||
with = "::serde_with::rust::double_option"
|
||||
)]
|
||||
#[validate(length(min = 1, max = 64), regex(path = *crate::util::validate::RE_USERNAME))]
|
||||
#[validate(length(min = 1, max = 64), regex(path = *crate::util::validate::RE_URL_SAFE))]
|
||||
pub name: Option<Option<String>>,
|
||||
#[serde(
|
||||
default,
|
||||
|
||||
@@ -36,7 +36,7 @@ pub struct InitialVersionData {
|
||||
pub file_parts: Vec<String>,
|
||||
#[validate(
|
||||
length(min = 1, max = 32),
|
||||
regex(path = *crate::util::validate::RE_URL_SAFE)
|
||||
regex(path = *crate::util::validate::RE_URL_SAFE_RELAXED)
|
||||
)]
|
||||
pub version_number: String,
|
||||
#[validate(
|
||||
|
||||
@@ -314,7 +314,7 @@ pub struct EditVersion {
|
||||
pub name: Option<String>,
|
||||
#[validate(
|
||||
length(min = 1, max = 32),
|
||||
regex(path = *crate::util::validate::RE_URL_SAFE)
|
||||
regex(path = *crate::util::validate::RE_URL_SAFE_RELAXED)
|
||||
)]
|
||||
pub version_number: Option<String>,
|
||||
#[validate(length(max = 65536))]
|
||||
|
||||
Reference in New Issue
Block a user