diff mbox series

[v3,7/7] efi_selftest: Update StrToFat() unit test after CP473 map extension

Message ID 20240316-vidconsole-utf8-uefi-v3-7-4e8a3d349447@jannau.net
State Accepted, archived
Commit 9566b3b321345e4d049611a17314e087d326f4c9
Delegated to: Heinrich Schuchardt
Headers show
Series video: Add UTF-8 support for UEFI applications | expand

Commit Message

Janne Grunau via B4 Relay March 16, 2024, 9:50 p.m. UTC
From: Janne Grunau <j@jannau.net>

Test that Unicode code points which map to CP437 code points 1-31 are
converted to '_'. This ensures no FAT file names do not contain chars
which are control characters in other code pages (CP 1250 for example).

Signed-off-by: Janne Grunau <j@jannau.net>
---
 lib/efi_selftest/efi_selftest_unicode_collation.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

Comments

Heinrich Schuchardt March 17, 2024, 9:44 a.m. UTC | #1
On 3/16/24 22:50, Janne Grunau via B4 Relay wrote:
> From: Janne Grunau <j@jannau.net>
>
> Test that Unicode code points which map to CP437 code points 1-31 are
> converted to '_'. This ensures no FAT file names do not contain chars
> which are control characters in other code pages (CP 1250 for example).
>
> Signed-off-by: Janne Grunau <j@jannau.net>
> ---
>   lib/efi_selftest/efi_selftest_unicode_collation.c | 12 ++++++++++++
>   1 file changed, 12 insertions(+)
>
> diff --git a/lib/efi_selftest/efi_selftest_unicode_collation.c b/lib/efi_selftest/efi_selftest_unicode_collation.c
> index 32c99caf35..ad7dfa9fb9 100644
> --- a/lib/efi_selftest/efi_selftest_unicode_collation.c
> +++ b/lib/efi_selftest/efi_selftest_unicode_collation.c
> @@ -220,6 +220,18 @@ static int test_str_to_fat(void)
>   		return EFI_ST_FAILURE;
>   	}
>
> +	/*
> +	 * Test unicode code points which map to CP 437 0x01 - 0x1f are
> +	 * converted to '_'.
> +	 */
> +	boottime->set_mem(fat, 16, 0);
> +	ret = unicode_collation_protocol->str_to_fat(unicode_collation_protocol,
> +		u"\u263a\u2666\u2022\u25d8\u2642\u2194\u00b6\u203c", 8, fat);
> +	if (!ret || efi_st_strcmp_16_8(u"________", fat)) {
> +		efi_st_error("str_to_fat returned %u, \"%s\"\n", ret, fat);
> +		return EFI_ST_FAILURE;
> +	}
> +

Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

>   	return EFI_ST_SUCCESS;
>   }
>
>
diff mbox series

Patch

diff --git a/lib/efi_selftest/efi_selftest_unicode_collation.c b/lib/efi_selftest/efi_selftest_unicode_collation.c
index 32c99caf35..ad7dfa9fb9 100644
--- a/lib/efi_selftest/efi_selftest_unicode_collation.c
+++ b/lib/efi_selftest/efi_selftest_unicode_collation.c
@@ -220,6 +220,18 @@  static int test_str_to_fat(void)
 		return EFI_ST_FAILURE;
 	}
 
+	/*
+	 * Test unicode code points which map to CP 437 0x01 - 0x1f are
+	 * converted to '_'.
+	 */
+	boottime->set_mem(fat, 16, 0);
+	ret = unicode_collation_protocol->str_to_fat(unicode_collation_protocol,
+		u"\u263a\u2666\u2022\u25d8\u2642\u2194\u00b6\u203c", 8, fat);
+	if (!ret || efi_st_strcmp_16_8(u"________", fat)) {
+		efi_st_error("str_to_fat returned %u, \"%s\"\n", ret, fat);
+		return EFI_ST_FAILURE;
+	}
+
 	return EFI_ST_SUCCESS;
 }