From c59690ad3384f140e4b65ed41fd095120c82f5a3 Mon Sep 17 00:00:00 2001 From: hafihaf123 Date: Sun, 2 Feb 2025 19:21:38 +0100 Subject: [PATCH] fix RobotsTag::is_valid_field_name --- .../src/headers/x_robots_tag_components/robots_tag.rs | 8 ++++++-- .../robots_tag_components/builder.rs | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/rama-http/src/headers/x_robots_tag_components/robots_tag.rs b/rama-http/src/headers/x_robots_tag_components/robots_tag.rs index aa216562..6a5d5b58 100644 --- a/rama-http/src/headers/x_robots_tag_components/robots_tag.rs +++ b/rama-http/src/headers/x_robots_tag_components/robots_tag.rs @@ -57,7 +57,7 @@ pub(crate) struct RobotsTag { max_video_preview: Option, no_translate: bool, no_image_index: bool, - unavailable_after: Option, // "A date must be specified in a format such as RFC 822, RFC 850, or ISO 8601." + unavailable_after: Option, // custom rules no_ai: bool, no_image_ai: bool, @@ -115,14 +115,18 @@ impl RobotsTag { getter_setter!(spc, bool); pub(super) fn is_valid_field_name(field_name: &str) -> bool { - field_name.eq_ignore_ascii_case("all") + field_name.trim().eq_ignore_ascii_case("all") || field_name.eq_ignore_ascii_case("noindex") || field_name.eq_ignore_ascii_case("nofollow") || field_name.eq_ignore_ascii_case("none") || field_name.eq_ignore_ascii_case("nosnippet") || field_name.eq_ignore_ascii_case("indexifembedded") + || field_name.eq_ignore_ascii_case("max-snippet") + || field_name.eq_ignore_ascii_case("max-image-preview") + || field_name.eq_ignore_ascii_case("max-video-preview") || field_name.eq_ignore_ascii_case("notranslate") || field_name.eq_ignore_ascii_case("noimageindex") + || field_name.eq_ignore_ascii_case("unavailable_after") || field_name.eq_ignore_ascii_case("noai") || field_name.eq_ignore_ascii_case("noimageai") || field_name.eq_ignore_ascii_case("spc") diff --git a/rama-http/src/headers/x_robots_tag_components/robots_tag_components/builder.rs b/rama-http/src/headers/x_robots_tag_components/robots_tag_components/builder.rs index 262ed31b..495778b4 100644 --- a/rama-http/src/headers/x_robots_tag_components/robots_tag_components/builder.rs +++ b/rama-http/src/headers/x_robots_tag_components/robots_tag_components/builder.rs @@ -68,7 +68,7 @@ impl Builder { self.0.bot_name = Some(bot_name); self } - + no_tag_builder_field!(all, bool); no_tag_builder_field!(no_index, bool); no_tag_builder_field!(no_follow, bool);