@@ -341,7 +341,11 @@ impl Style {
341341 "reverse" => rv. reverse ( ) ,
342342 "hidden" => rv. hidden ( ) ,
343343 "strikethrough" => rv. strikethrough ( ) ,
344- on_true_color if on_true_color. starts_with ( "on_#" ) && on_true_color. len ( ) == 10 => {
344+ on_true_color
345+ if on_true_color. starts_with ( "on_#" )
346+ && on_true_color. len ( ) == 10
347+ && on_true_color. is_ascii ( ) =>
348+ {
345349 if let ( Ok ( r) , Ok ( g) , Ok ( b) ) = (
346350 u8:: from_str_radix ( & on_true_color[ 4 ..6 ] , 16 ) ,
347351 u8:: from_str_radix ( & on_true_color[ 6 ..8 ] , 16 ) ,
@@ -352,7 +356,11 @@ impl Style {
352356 continue ;
353357 }
354358 }
355- true_color if true_color. starts_with ( '#' ) && true_color. len ( ) == 7 => {
359+ true_color
360+ if true_color. starts_with ( '#' )
361+ && true_color. len ( ) == 7
362+ && true_color. is_ascii ( ) =>
363+ {
356364 if let ( Ok ( r) , Ok ( g) , Ok ( b) ) = (
357365 u8:: from_str_radix ( & true_color[ 1 ..3 ] , 16 ) ,
358366 u8:: from_str_radix ( & true_color[ 3 ..5 ] , 16 ) ,
@@ -1197,8 +1205,6 @@ fn test_attributes_many() {
11971205}
11981206
11991207#[ test]
1200- // NOTE: Documenting the current panic message. Ideally this input should be silently ignored
1201- #[ should_panic = "end byte index 3 is not a char boundary; it is inside '€' (bytes 1..4 of string)" ]
12021208fn test_style_from_non_ascii_fg ( ) {
12031209 // len() == 7, starts_with('#'), but slices [1..3] land mid-€ (3 bytes)
12041210 let fg = "#€€" ;
@@ -1211,8 +1217,6 @@ fn test_style_from_non_ascii_fg() {
12111217}
12121218
12131219#[ test]
1214- // NOTE: Documenting the current panic message. Ideally this input should be silently ignored
1215- #[ should_panic = "end byte index 6 is not a char boundary; it is inside '€' (bytes 4..7 of string)" ]
12161220fn test_style_from_non_ascii_bg ( ) {
12171221 // len() == 10, starts_with("on_#"), but slices [4..6] land mid-€
12181222 let bg = "on_#€€" ;
0 commit comments