From e47fd94473ddb4a3f9788421df66f83b4778a831 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Wed, 28 Oct 2026 15:24:37 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=92=20harden:=20a=20push's=20pack=20is?= =?UTF-8?q?=20capped=20at=202=20GiB=20(receive.maxInputSize),=20so=20a=20p?= =?UTF-8?q?ush=20or=20an=20inflating=20gzip=20body=20cannot=20fill=20the?= =?UTF-8?q?=20disk;=20label=20descriptions=20are=20capped=20at=20500=20cha?= =?UTF-8?q?racters=20and=20a=20repo=20at=20500=20labels;=20=F0=9F=90=9B=20?= =?UTF-8?q?fix:=20/assets=20with=20a=20stale=20or=20missing=20=3Fv=3D=20re?= =?UTF-8?q?validates=20instead=20of=20being=20cached=20as=20immutable=20fo?= =?UTF-8?q?r=20a=20year?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude --- crates/forge-core/src/issues.rs | 26 ++++++---- crates/forge-core/src/store/labels.rs | 19 +++++++- crates/forge-git/src/service.rs | 8 ++++ crates/forge-web/src/importer/mod.rs | 7 ++- crates/forge-web/src/pages/assets.rs | 58 +++++++++++++---------- crates/forge-web/src/pages/labels_page.rs | 4 +- 6 files changed, 84 insertions(+), 38 deletions(-) diff --git a/crates/forge-core/src/issues.rs b/crates/forge-core/src/issues.rs index e3c876a..c330af3 100644 --- a/crates/forge-core/src/issues.rs +++ b/crates/forge-core/src/issues.rs @@ -10,6 +10,8 @@ pub const MAX_TITLE: usize = 256; pub const MAX_BODY: usize = 65536; /// Longest accepted label name, in characters. pub const MAX_LABEL_NAME: usize = 50; +/// Longest label description, in characters. +pub const MAX_LABEL_DESCRIPTION: usize = 500; /// Most assignees one issue can have. pub const MAX_ASSIGNEES: usize = 10; @@ -251,7 +253,7 @@ pub fn validate_body(b: &str) -> Result<()> { /// Returns `(trimmed name, normalized color)`. The name is 1..=50 characters with no control /// characters. The color is `#rgb` or `#rrggbb` in any case and comes back as lowercase `#rrggbb`. -pub fn validate_label(name: &str, color: &str) -> Result<(String, String)> { +pub fn validate_label(name: &str, color: &str, description: &str) -> Result<(String, String)> { let name = name.trim(); let len = name.chars().count(); if len == 0 || len > MAX_LABEL_NAME { @@ -266,6 +268,11 @@ pub fn validate_label(name: &str, color: &str) -> Result<(String, String)> { } let color = normalize_color(color) .ok_or_else(|| Error::Invalid(format!("label color {color:?} is not #rgb or #rrggbb")))?; + if description.chars().count() > MAX_LABEL_DESCRIPTION { + return Err(Error::Invalid(format!( + "label description must be at most {MAX_LABEL_DESCRIPTION} characters" + ))); + } Ok((name.to_string(), color)) } @@ -321,18 +328,19 @@ mod tests { #[test] fn label_name_and_color_are_normalized() { assert_eq!( - validate_label(" bug ", "#FF0000").unwrap(), + validate_label(" bug ", "#FF0000", "").unwrap(), ("bug".to_string(), "#ff0000".to_string()) ); assert_eq!( - validate_label("x", "#AbC").unwrap(), + validate_label("x", "#AbC", "").unwrap(), ("x".to_string(), "#aabbcc".to_string()) ); - assert!(validate_label("", "#fff").is_err()); - assert!(validate_label(" ", "#fff").is_err()); - assert!(validate_label(&"a".repeat(MAX_LABEL_NAME), "#fff").is_ok()); - assert!(validate_label(&"a".repeat(MAX_LABEL_NAME + 1), "#fff").is_err()); - assert!(validate_label("a\u{7}", "#fff").is_err()); + assert!(validate_label("", "#fff", "").is_err()); + assert!(validate_label(" ", "#fff", "").is_err()); + assert!(validate_label(&"a".repeat(MAX_LABEL_NAME), "#fff", "").is_ok()); + assert!(validate_label(&"a".repeat(MAX_LABEL_NAME + 1), "#fff", "").is_err()); + assert!(validate_label("a\u{7}", "#fff", "").is_err()); + assert!(validate_label("x", "#fff", &"d".repeat(MAX_LABEL_DESCRIPTION + 1)).is_err()); } #[test] @@ -340,7 +348,7 @@ mod tests { for bad in [ "", "fff", "#ff", "#ffff", "#fffffff", "#gggggg", "red", "# fff", "#ff00 0", ] { - assert!(validate_label("x", bad).is_err(), "{bad:?} accepted"); + assert!(validate_label("x", bad, "").is_err(), "{bad:?} accepted"); } } diff --git a/crates/forge-core/src/store/labels.rs b/crates/forge-core/src/store/labels.rs index 49c405b..af1527f 100644 --- a/crates/forge-core/src/store/labels.rs +++ b/crates/forge-core/src/store/labels.rs @@ -20,6 +20,8 @@ use crate::time::now_stamp; /// Most assignees one issue can have. pub const MAX_ASSIGNEES: usize = 10; +/// Most labels one repo can have. +pub const MAX_LABELS: i64 = 500; const LABEL_TAKEN: &str = "a label with that name already exists"; const MILESTONE_TAKEN: &str = "a milestone with that title already exists"; @@ -92,7 +94,7 @@ impl Store { color: &str, description: &str, ) -> Result
@@ -157,7 +157,7 @@ async fn labels_body(