From 7ba101c188d2f8274e91d98efc50142586d7c856 Mon Sep 17 00:00:00 2001 From: Ruud van Asseldonk Date: Thu, 11 Aug 2022 13:42:40 +0200 Subject: [PATCH] Improve validator name sanitizer One of the validators in the last onboarding wave has U+26A1 HIGH VOLTAGE SIGN and U+FE0F VARIATION SELECTOR-16 in its name. In my terminal, these render as a lightning bolt using an emoji font. Also, due to the way we render labels when rendering the metrics, the variation selector turns into the literal text "\u{fe0f}" (so a backslash and hex between curly brackets, not an U+FE0F itself). Strip code points from both blocks to fix this. --- cli/maintainer/src/maintenance.rs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/cli/maintainer/src/maintenance.rs b/cli/maintainer/src/maintenance.rs index 301cffc1c..dd5660be2 100644 --- a/cli/maintainer/src/maintenance.rs +++ b/cli/maintainer/src/maintenance.rs @@ -420,13 +420,22 @@ fn sanitize_validator_name(name: &str) -> String { // adds no information, strip it here to leave more space for graphs in // dashboards, and not waste so much space on the redundant part of the name. match name.strip_prefix("Lido / ") { - // I don't want distracting emojis in my Grafana dashboards, so remove - // code points in the Supplementary Multilingual Plane and beyond. This - // strips emojis and dingbats while leaving letters and punctuation of - // all contemporary languages. + // I don't want distracting emojis in my Grafana dashboards. Some(suffix) => suffix .chars() - .filter(|&ch| ch < '\u{10000}') + .filter(|&ch| + // Remove code points in the Supplementary Multilingual Plane and + // beyond. This strips most emojis and dingbats while leaving + // letters and punctuation of all contemporary languages. + ch < '\u{10000}' + // Remove variation selectors. These can be used to make code + // points that are traditionally not emoji, render as emoji. + && (ch < '\u{fe00}' || ch > '\u{fe0f}') + // Remove code points from the Miscellaneous Symbols block, + // which contains dingbats that predate emoji, but nowadays + // are usually rendered with colored emoji font instead of an + // outline glyph. + && (ch < '\u{2600}' || ch > '\u{26ff}')) .collect::() .trim() .to_string(),