notecrumbs

a nostr opengraph server build on nostrdb and egui
git clone git://jb55.com/notecrumbs
Log | Files | Refs | README | LICENSE

commit 3c28578d5e160a58629d020d671be91efba10c0f
parent b4d8a72c9cda23a6511287a9c67eb108f7b00014
Author: William Casarin <jb55@jb55.com>
Date:   Thu, 18 Dec 2025 10:14:20 -0800

fix potential panic in ends_with

Signed-off-by: William Casarin <jb55@jb55.com>

Diffstat:
Msrc/html.rs | 8++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/html.rs b/src/html.rs @@ -221,8 +221,12 @@ pub fn serve_note_json( } fn ends_with(haystack: &str, needle: &str) -> bool { - haystack.len() >= needle.len() - && haystack[haystack.len() - needle.len()..].eq_ignore_ascii_case(needle) + if haystack.len() < needle.len() { + return false; + } + haystack + .get(haystack.len() - needle.len()..) + .is_some_and(|tail| tail.eq_ignore_ascii_case(needle)) } fn is_image(url: &str) -> bool {