Skip to content

Commit 0640103

Browse files
authored
Merge pull request #2950 from DeusData/distill/2219-fqn-unicode-collision-guard
test(fqn): guard against Unicode project-name collisions
2 parents f61d7c0 + fcf274a commit 0640103

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

‎tests/test_fqn.c‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,23 @@ TEST(project_name_encodes_unicode_segments_issue571) {
630630
PASS();
631631
}
632632

633+
TEST(project_name_unicode_segments_do_not_collide_issue571) {
634+
char *first = cbm_project_name_from_path("/Users/dev/\xe5\xbc\x80\xe5\x8f\x91");
635+
char *second = cbm_project_name_from_path("/Users/dev/\xe5\x90\x8e\xe7\xab\xaf");
636+
ASSERT_NOT_NULL(first);
637+
ASSERT_NOT_NULL(second);
638+
ASSERT_STR_NEQ(first, second);
639+
/* Distinct is not enough: each name must carry the hex image of its own
640+
* non-ASCII segment, so the segment is preserved rather than replaced. */
641+
ASSERT_NOT_NULL(strstr(first, "e5bc80e58f91"));
642+
ASSERT_NOT_NULL(strstr(second, "e5908ee7abaf"));
643+
ASSERT_TRUE(cbm_validate_project_name(first));
644+
ASSERT_TRUE(cbm_validate_project_name(second));
645+
free(first);
646+
free(second);
647+
PASS();
648+
}
649+
633650
/* issue #624: #571 preserves non-ASCII path segments by hex-encoding each byte
634651
* (1 byte -> 2 hex chars), so a DEEP non-ASCII path triples in length and can
635652
* blow past the filesystem's 255-byte filename-component limit. Then
@@ -802,6 +819,7 @@ SUITE(fqn) {
802819
RUN_TEST(project_name_deep_path);
803820
RUN_TEST(project_name_always_validator_safe_issue349);
804821
RUN_TEST(project_name_encodes_unicode_segments_issue571);
822+
RUN_TEST(project_name_unicode_segments_do_not_collide_issue571);
805823
RUN_TEST(project_name_length_capped_issue624);
806824
RUN_TEST(project_name_colon_only);
807825
RUN_TEST(project_name_backslash_only);

0 commit comments

Comments
 (0)