...
|
...
|
@@ -891,95 +891,268 @@ END_TEST
|
891
|
891
|
|
892
|
892
|
START_TEST(test_sanitize_path)
|
893
|
893
|
{
|
894
|
|
- char *sanitized = NULL;
|
895
|
|
- const char *unsanitized = NULL;
|
|
894
|
+ const char *unsanitized = NULL;
|
|
895
|
+ char *sanitized = NULL;
|
|
896
|
+ char *sanitized_base = NULL;
|
|
897
|
+ const char *expected = NULL;
|
|
898
|
+ const char *expected_base = NULL;
|
896
|
899
|
|
897
|
900
|
unsanitized = "";
|
898
|
|
- sanitized = cli_sanitize_filepath(unsanitized, strlen(unsanitized));
|
899
|
|
- ck_assert_msg(NULL == sanitized, "sanitize_path: Empty path test failed");
|
|
901
|
+ sanitized = cli_sanitize_filepath(unsanitized, strlen(unsanitized), NULL);
|
|
902
|
+ ck_assert_msg(NULL == sanitized, "Expected: NULL, Found: \"%s\"", sanitized);
|
|
903
|
+
|
|
904
|
+ unsanitized = "";
|
|
905
|
+ sanitized = cli_sanitize_filepath(unsanitized, strlen(unsanitized), &sanitized_base);
|
|
906
|
+ ck_assert_msg(NULL == sanitized, "Expected: NULL, Found: \"%s\"", sanitized);
|
|
907
|
+ ck_assert_msg(NULL == sanitized_base, "Expected: NULL, Found: \"%s\"", sanitized_base);
|
|
908
|
+
|
|
909
|
+ unsanitized = NULL;
|
|
910
|
+ sanitized = cli_sanitize_filepath(unsanitized, 0, NULL);
|
|
911
|
+ ck_assert_msg(NULL == sanitized, "Expected: NULL, Found: \"%s\"", sanitized);
|
900
|
912
|
|
901
|
913
|
unsanitized = NULL;
|
902
|
|
- sanitized = cli_sanitize_filepath(unsanitized, 0);
|
903
|
|
- ck_assert_msg(NULL == sanitized, "sanitize_path: NULL path #1 test failed");
|
|
914
|
+ sanitized = cli_sanitize_filepath(unsanitized, 0, &sanitized_base);
|
|
915
|
+ ck_assert_msg(NULL == sanitized, "Expected: NULL, Found: \"%s\"", sanitized);
|
|
916
|
+ ck_assert_msg(NULL == sanitized_base, "Expected: NULL, Found: \"%s\"", sanitized_base);
|
904
|
917
|
|
905
|
918
|
unsanitized = NULL;
|
906
|
|
- sanitized = cli_sanitize_filepath(unsanitized, 50);
|
907
|
|
- ck_assert_msg(NULL == sanitized, "sanitize_path: NULL path #2 test failed");
|
|
919
|
+ sanitized = cli_sanitize_filepath(unsanitized, 50, NULL);
|
|
920
|
+ ck_assert_msg(NULL == sanitized, "Expected: NULL, Found: \"%s\"", sanitized);
|
|
921
|
+
|
|
922
|
+ unsanitized = NULL;
|
|
923
|
+ sanitized = cli_sanitize_filepath(unsanitized, 50, &sanitized_base);
|
|
924
|
+ ck_assert_msg(NULL == sanitized, "Expected: NULL, Found: \"%s\"", sanitized);
|
|
925
|
+ ck_assert_msg(NULL == sanitized_base, "Expected: NULL, Found: \"%s\"", sanitized_base);
|
|
926
|
+
|
|
927
|
+ unsanitized = "badlen";
|
|
928
|
+ sanitized = cli_sanitize_filepath(unsanitized, 0, NULL);
|
|
929
|
+ ck_assert_msg(NULL == sanitized, "Expected: NULL, Found: \"%s\"", sanitized);
|
908
|
930
|
|
909
|
931
|
unsanitized = "badlen";
|
910
|
|
- sanitized = cli_sanitize_filepath(unsanitized, 0);
|
911
|
|
- ck_assert_msg(NULL == sanitized, "sanitize_path: Zero/bad path length test failed");
|
|
932
|
+ sanitized = cli_sanitize_filepath(unsanitized, 0, &sanitized_base);
|
|
933
|
+ ck_assert_msg(NULL == sanitized, "Expected: NULL, Found: \"%s\"", sanitized);
|
|
934
|
+ ck_assert_msg(NULL == sanitized_base, "Expected: NULL, Found: \"%s\"", sanitized_base);
|
|
935
|
+
|
|
936
|
+ unsanitized = ".." PATHSEP;
|
|
937
|
+ sanitized = cli_sanitize_filepath(unsanitized, strlen(unsanitized), NULL);
|
|
938
|
+ ck_assert_msg(NULL == sanitized, "Expected: NULL, Found: \"%s\"", sanitized);
|
912
|
939
|
|
913
|
940
|
unsanitized = ".." PATHSEP;
|
914
|
|
- sanitized = cli_sanitize_filepath(unsanitized, strlen(unsanitized));
|
915
|
|
- ck_assert_msg(NULL == sanitized, "sanitize_path: sanitized path should have been NULL");
|
|
941
|
+ sanitized = cli_sanitize_filepath(unsanitized, strlen(unsanitized), &sanitized_base);
|
|
942
|
+ ck_assert_msg(NULL == sanitized, "Expected: NULL, Found: \"%s\"", sanitized);
|
|
943
|
+ ck_assert_msg(NULL == sanitized_base, "Expected: NULL, Found: \"%s\"", sanitized_base);
|
916
|
944
|
|
917
|
945
|
unsanitized = "." PATHSEP;
|
918
|
|
- sanitized = cli_sanitize_filepath(unsanitized, strlen(unsanitized));
|
919
|
|
- ck_assert_msg(NULL == sanitized, "sanitize_path: sanitized path should have been NULL (2)");
|
|
946
|
+ sanitized = cli_sanitize_filepath(unsanitized, strlen(unsanitized), NULL);
|
|
947
|
+ ck_assert_msg(NULL == sanitized, "Expected: NULL, Found: \"%s\"", sanitized);
|
|
948
|
+
|
|
949
|
+ unsanitized = "." PATHSEP;
|
|
950
|
+ sanitized = cli_sanitize_filepath(unsanitized, strlen(unsanitized), &sanitized_base);
|
|
951
|
+ ck_assert_msg(NULL == sanitized, "Expected: NULL, Found: \"%s\"", sanitized);
|
|
952
|
+ ck_assert_msg(NULL == sanitized_base, "Expected: NULL, Found: \"%s\"", sanitized_base);
|
920
|
953
|
|
921
|
954
|
unsanitized = PATHSEP;
|
922
|
|
- sanitized = cli_sanitize_filepath(unsanitized, strlen(unsanitized));
|
|
955
|
+ sanitized = cli_sanitize_filepath(unsanitized, strlen(unsanitized), NULL);
|
923
|
956
|
ck_assert_msg(NULL == sanitized, "sanitize_path: sanitized path should have been NULL (3)");
|
924
|
957
|
|
|
958
|
+ unsanitized = PATHSEP;
|
|
959
|
+ sanitized = cli_sanitize_filepath(unsanitized, strlen(unsanitized), &sanitized_base);
|
|
960
|
+ ck_assert_msg(NULL == sanitized, "Expected: NULL, Found: \"%s\"", sanitized);
|
|
961
|
+ ck_assert_msg(NULL == sanitized_base, "Expected: NULL, Found: \"%s\"", sanitized_base);
|
|
962
|
+
|
925
|
963
|
unsanitized = ".." PATHSEP "relative_bad_1";
|
926
|
|
- sanitized = cli_sanitize_filepath(unsanitized, strlen(unsanitized));
|
|
964
|
+ expected = "relative_bad_1";
|
|
965
|
+ sanitized = cli_sanitize_filepath(unsanitized, strlen(unsanitized), NULL);
|
927
|
966
|
ck_assert(NULL != sanitized);
|
928
|
|
- ck_assert_msg(!strcmp(sanitized, "relative_bad_1"), "sanitize_path: bad relative path test #1 failed");
|
|
967
|
+ ck_assert_msg(!strcmp(expected, sanitized), "Expected: \"%s\", Found: \"%s\"", expected, sanitized);
|
|
968
|
+ free(sanitized);
|
|
969
|
+
|
|
970
|
+ unsanitized = ".." PATHSEP "relative_bad_1";
|
|
971
|
+ expected = "relative_bad_1";
|
|
972
|
+ expected_base = "relative_bad_1";
|
|
973
|
+ sanitized = cli_sanitize_filepath(unsanitized, strlen(unsanitized), &sanitized_base);
|
|
974
|
+ ck_assert(NULL != sanitized);
|
|
975
|
+ ck_assert(NULL != sanitized_base);
|
|
976
|
+ ck_assert_msg(!strcmp(expected, sanitized), "Expected: \"%s\", Found: \"%s\"", expected, sanitized);
|
|
977
|
+ ck_assert_msg(!strcmp(expected_base, sanitized_base), "Expected: \"%s\", Found: \"%s\"", expected_base, sanitized_base);
|
929
|
978
|
free(sanitized);
|
930
|
979
|
|
931
|
980
|
unsanitized = "relative" PATHSEP ".." PATHSEP "good";
|
932
|
|
- sanitized = cli_sanitize_filepath(unsanitized, strlen(unsanitized));
|
|
981
|
+ expected = "relative" PATHSEP ".." PATHSEP "good";
|
|
982
|
+ sanitized = cli_sanitize_filepath(unsanitized, strlen(unsanitized), NULL);
|
933
|
983
|
ck_assert(NULL != sanitized);
|
934
|
|
- ck_assert_msg(!strcmp(sanitized, "relative" PATHSEP ".." PATHSEP "good"), "sanitize_path: good relative path test failed");
|
|
984
|
+ ck_assert_msg(!strcmp(expected, sanitized), "Expected: \"%s\", Found: \"%s\"", expected, sanitized);
|
|
985
|
+ free(sanitized);
|
|
986
|
+
|
|
987
|
+ unsanitized = "relative" PATHSEP ".." PATHSEP "good";
|
|
988
|
+ expected = "relative" PATHSEP ".." PATHSEP "good";
|
|
989
|
+ expected_base = "good";
|
|
990
|
+ sanitized = cli_sanitize_filepath(unsanitized, strlen(unsanitized), &sanitized_base);
|
|
991
|
+ ck_assert(NULL != sanitized);
|
|
992
|
+ ck_assert(NULL != sanitized_base);
|
|
993
|
+ ck_assert_msg(!strcmp(expected, sanitized), "Expected: \"%s\", Found: \"%s\"", expected, sanitized);
|
|
994
|
+ ck_assert_msg(!strcmp(expected_base, sanitized_base), "Expected: \"%s\", Found: \"%s\"", expected_base, sanitized_base);
|
935
|
995
|
free(sanitized);
|
936
|
996
|
|
937
|
997
|
unsanitized = "relative" PATHSEP ".." PATHSEP ".." PATHSEP "bad_2";
|
938
|
|
- sanitized = cli_sanitize_filepath(unsanitized, strlen(unsanitized));
|
|
998
|
+ expected = "relative" PATHSEP ".." PATHSEP "bad_2";
|
|
999
|
+ sanitized = cli_sanitize_filepath(unsanitized, strlen(unsanitized), NULL);
|
|
1000
|
+ ck_assert(NULL != sanitized);
|
|
1001
|
+ ck_assert_msg(!strcmp(expected, sanitized), "Expected: \"%s\", Found: \"%s\"", expected, sanitized);
|
|
1002
|
+ free(sanitized);
|
|
1003
|
+
|
|
1004
|
+ unsanitized = "relative" PATHSEP ".." PATHSEP ".." PATHSEP "bad_2";
|
|
1005
|
+ expected = "relative" PATHSEP ".." PATHSEP "bad_2";
|
|
1006
|
+ expected_base = "bad_2";
|
|
1007
|
+ sanitized = cli_sanitize_filepath(unsanitized, strlen(unsanitized), &sanitized_base);
|
939
|
1008
|
ck_assert(NULL != sanitized);
|
940
|
|
- ck_assert_msg(!strcmp(sanitized, "relative" PATHSEP ".." PATHSEP "bad_2"), "sanitize_path: bad relative path test failed");
|
|
1009
|
+ ck_assert(NULL != sanitized_base);
|
|
1010
|
+ ck_assert_msg(!strcmp(expected, sanitized), "Expected: \"%s\", Found: \"%s\"", expected, sanitized);
|
|
1011
|
+ ck_assert_msg(!strcmp(expected_base, sanitized_base), "Expected: \"%s\", Found: \"%s\"", expected_base, sanitized_base);
|
941
|
1012
|
free(sanitized);
|
942
|
1013
|
|
943
|
1014
|
unsanitized = "relative" PATHSEP "." PATHSEP ".." PATHSEP ".." PATHSEP "bad_current";
|
944
|
|
- sanitized = cli_sanitize_filepath(unsanitized, strlen(unsanitized));
|
|
1015
|
+ expected = "relative" PATHSEP ".." PATHSEP "bad_current";
|
|
1016
|
+ sanitized = cli_sanitize_filepath(unsanitized, strlen(unsanitized), NULL);
|
945
|
1017
|
ck_assert(NULL != sanitized);
|
946
|
1018
|
ck_assert_msg(!strcmp(sanitized, "relative" PATHSEP ".." PATHSEP "bad_current"), "sanitize_path: bad relative current path test failed");
|
|
1019
|
+ ck_assert_msg(!strcmp(expected, sanitized), "Expected: \"%s\", Found: \"%s\"", expected, sanitized);
|
|
1020
|
+ free(sanitized);
|
|
1021
|
+
|
|
1022
|
+ unsanitized = "relative" PATHSEP "." PATHSEP ".." PATHSEP ".." PATHSEP "bad_current";
|
|
1023
|
+ expected = "relative" PATHSEP ".." PATHSEP "bad_current";
|
|
1024
|
+ expected_base = "bad_current";
|
|
1025
|
+ sanitized = cli_sanitize_filepath(unsanitized, strlen(unsanitized), &sanitized_base);
|
|
1026
|
+ ck_assert(NULL != sanitized);
|
|
1027
|
+ ck_assert(NULL != sanitized_base);
|
|
1028
|
+ ck_assert_msg(!strcmp(expected, sanitized), "Expected: \"%s\", Found: \"%s\"", expected, sanitized);
|
|
1029
|
+ ck_assert_msg(!strcmp(expected_base, sanitized_base), "Expected: \"%s\", Found: \"%s\"", expected_base, sanitized_base);
|
947
|
1030
|
free(sanitized);
|
948
|
1031
|
|
949
|
1032
|
unsanitized = "relative/../../bad_win_posix_path";
|
950
|
|
- sanitized = cli_sanitize_filepath(unsanitized, strlen(unsanitized));
|
|
1033
|
+#ifdef _WIN32
|
|
1034
|
+ expected = "relative\\..\\bad_win_posix_path";
|
|
1035
|
+#else
|
|
1036
|
+ expected = "relative/../bad_win_posix_path";
|
|
1037
|
+#endif
|
|
1038
|
+ sanitized = cli_sanitize_filepath(unsanitized, strlen(unsanitized), NULL);
|
951
|
1039
|
ck_assert(NULL != sanitized);
|
952
|
|
- ck_assert_msg(!strcmp(sanitized, "relative/../bad_win_posix_path"), "sanitize_path: bad relative win posix path test failed");
|
|
1040
|
+ ck_assert_msg(!strcmp(expected, sanitized), "Expected: \"%s\", Found: \"%s\"", expected, sanitized);
|
|
1041
|
+ free(sanitized);
|
|
1042
|
+
|
|
1043
|
+ unsanitized = "relative/../../bad_win_posix_path";
|
|
1044
|
+#ifdef _WIN32
|
|
1045
|
+ expected = "relative\\..\\bad_win_posix_path";
|
|
1046
|
+#else
|
|
1047
|
+ expected = "relative/../bad_win_posix_path";
|
|
1048
|
+#endif
|
|
1049
|
+ expected_base = "bad_win_posix_path";
|
|
1050
|
+ sanitized = cli_sanitize_filepath(unsanitized, strlen(unsanitized), &sanitized_base);
|
|
1051
|
+ ck_assert(NULL != sanitized);
|
|
1052
|
+ ck_assert(NULL != sanitized_base);
|
|
1053
|
+ ck_assert_msg(!strcmp(expected, sanitized), "Expected: \"%s\", Found: \"%s\"", expected, sanitized);
|
|
1054
|
+ ck_assert_msg(!strcmp(expected_base, sanitized_base), "Expected: \"%s\", Found: \"%s\"", expected_base, sanitized_base);
|
953
|
1055
|
free(sanitized);
|
954
|
1056
|
|
955
|
1057
|
unsanitized = "" PATHSEP "absolute" PATHSEP ".." PATHSEP ".." PATHSEP "bad";
|
956
|
|
- sanitized = cli_sanitize_filepath(unsanitized, strlen(unsanitized));
|
|
1058
|
+ expected = "absolute" PATHSEP ".." PATHSEP "bad";
|
|
1059
|
+ sanitized = cli_sanitize_filepath(unsanitized, strlen(unsanitized), NULL);
|
|
1060
|
+ ck_assert(NULL != sanitized);
|
|
1061
|
+ ck_assert_msg(!strcmp(expected, sanitized), "Expected: \"%s\", Found: \"%s\"", expected, sanitized);
|
|
1062
|
+ free(sanitized);
|
|
1063
|
+
|
|
1064
|
+ unsanitized = "" PATHSEP "absolute" PATHSEP ".." PATHSEP ".." PATHSEP "bad";
|
|
1065
|
+ expected = "absolute" PATHSEP ".." PATHSEP "bad";
|
|
1066
|
+ expected_base = "bad";
|
|
1067
|
+ sanitized = cli_sanitize_filepath(unsanitized, strlen(unsanitized), &sanitized_base);
|
957
|
1068
|
ck_assert(NULL != sanitized);
|
958
|
|
- ck_assert_msg(!strcmp(sanitized, "absolute" PATHSEP ".." PATHSEP "bad"), "sanitize_path: bad absolute path test failed");
|
|
1069
|
+ ck_assert(NULL != sanitized_base);
|
|
1070
|
+ ck_assert_msg(!strcmp(expected, sanitized), "Expected: \"%s\", Found: \"%s\"", expected, sanitized);
|
|
1071
|
+ ck_assert_msg(!strcmp(expected_base, sanitized_base), "Expected: \"%s\", Found: \"%s\"", expected_base, sanitized_base);
|
959
|
1072
|
free(sanitized);
|
960
|
1073
|
|
961
|
1074
|
unsanitized = "" PATHSEP "absolute" PATHSEP ".." PATHSEP "good";
|
962
|
|
- sanitized = cli_sanitize_filepath(unsanitized, strlen(unsanitized));
|
|
1075
|
+ expected = "absolute" PATHSEP ".." PATHSEP "good";
|
|
1076
|
+ sanitized = cli_sanitize_filepath(unsanitized, strlen(unsanitized), NULL);
|
963
|
1077
|
ck_assert(NULL != sanitized);
|
964
|
|
- ck_assert_msg(!strcmp(sanitized, "absolute" PATHSEP ".." PATHSEP "good"), "sanitize_path: good absolute path test failed");
|
|
1078
|
+ ck_assert_msg(!strcmp(expected, sanitized), "Expected: \"%s\", Found: \"%s\"", expected, sanitized);
|
|
1079
|
+ free(sanitized);
|
|
1080
|
+
|
|
1081
|
+ unsanitized = "" PATHSEP "absolute" PATHSEP ".." PATHSEP "good";
|
|
1082
|
+ expected = "absolute" PATHSEP ".." PATHSEP "good";
|
|
1083
|
+ expected_base = "good";
|
|
1084
|
+ sanitized = cli_sanitize_filepath(unsanitized, strlen(unsanitized), &sanitized_base);
|
|
1085
|
+ ck_assert(NULL != sanitized);
|
|
1086
|
+ ck_assert(NULL != sanitized_base);
|
|
1087
|
+ ck_assert_msg(!strcmp(expected, sanitized), "Expected: \"%s\", Found: \"%s\"", expected, sanitized);
|
|
1088
|
+ ck_assert_msg(!strcmp(expected_base, sanitized_base), "Expected: \"%s\", Found: \"%s\"", expected_base, sanitized_base);
|
965
|
1089
|
free(sanitized);
|
966
|
1090
|
|
967
|
1091
|
unsanitized = "relative" PATHSEP "normal";
|
968
|
|
- sanitized = cli_sanitize_filepath(unsanitized, strlen(unsanitized));
|
|
1092
|
+ expected = "relative" PATHSEP "normal";
|
|
1093
|
+ sanitized = cli_sanitize_filepath(unsanitized, strlen(unsanitized), NULL);
|
969
|
1094
|
ck_assert(NULL != sanitized);
|
970
|
|
- ck_assert_msg(!strcmp(sanitized, "relative" PATHSEP "normal"), "sanitize_path: relative normal path test failed");
|
|
1095
|
+ ck_assert_msg(!strcmp(expected, sanitized), "Expected: \"%s\", Found: \"%s\"", expected, sanitized);
|
|
1096
|
+ free(sanitized);
|
|
1097
|
+
|
|
1098
|
+ unsanitized = "relative" PATHSEP "normal";
|
|
1099
|
+ expected = "relative" PATHSEP "normal";
|
|
1100
|
+ expected_base = "normal";
|
|
1101
|
+ sanitized = cli_sanitize_filepath(unsanitized, strlen(unsanitized), &sanitized_base);
|
|
1102
|
+ ck_assert(NULL != sanitized);
|
|
1103
|
+ ck_assert(NULL != sanitized_base);
|
|
1104
|
+ ck_assert_msg(!strcmp(expected, sanitized), "Expected: \"%s\", Found: \"%s\"", expected, sanitized);
|
|
1105
|
+ ck_assert_msg(!strcmp(expected_base, sanitized_base), "Expected: \"%s\", Found: \"%s\"", expected_base, sanitized_base);
|
971
|
1106
|
free(sanitized);
|
972
|
1107
|
|
973
|
1108
|
unsanitized = "relative" PATHSEP PATHSEP "doublesep";
|
974
|
|
- sanitized = cli_sanitize_filepath(unsanitized, strlen(unsanitized));
|
|
1109
|
+ expected = "relative" PATHSEP "doublesep";
|
|
1110
|
+ sanitized = cli_sanitize_filepath(unsanitized, strlen(unsanitized), NULL);
|
|
1111
|
+ ck_assert(NULL != sanitized);
|
|
1112
|
+ ck_assert_msg(!strcmp(expected, sanitized), "Expected: \"%s\", Found: \"%s\"", expected, sanitized);
|
|
1113
|
+ free(sanitized);
|
|
1114
|
+
|
|
1115
|
+ unsanitized = "relative" PATHSEP PATHSEP "doublesep";
|
|
1116
|
+ expected = "relative" PATHSEP "doublesep";
|
|
1117
|
+ expected_base = "doublesep";
|
|
1118
|
+ sanitized = cli_sanitize_filepath(unsanitized, strlen(unsanitized), &sanitized_base);
|
975
|
1119
|
ck_assert(NULL != sanitized);
|
976
|
|
- ck_assert_msg(!strcmp(sanitized, "relative" PATHSEP "doublesep"), "sanitize_path: relative double sep path test failed");
|
|
1120
|
+ ck_assert(NULL != sanitized_base);
|
|
1121
|
+ ck_assert_msg(!strcmp(expected, sanitized), "Expected: \"%s\", Found: \"%s\"", expected, sanitized);
|
|
1122
|
+ ck_assert_msg(!strcmp(expected_base, sanitized_base), "Expected: \"%s\", Found: \"%s\"", expected_base, sanitized_base);
|
977
|
1123
|
free(sanitized);
|
978
|
1124
|
|
979
|
1125
|
unsanitized = "relative" PATHSEP "shortname" PATHSEP "1";
|
980
|
|
- sanitized = cli_sanitize_filepath(unsanitized, strlen(unsanitized));
|
|
1126
|
+ expected = "relative" PATHSEP "shortname" PATHSEP "1";
|
|
1127
|
+ sanitized = cli_sanitize_filepath(unsanitized, strlen(unsanitized), NULL);
|
|
1128
|
+ ck_assert(NULL != sanitized);
|
|
1129
|
+ ck_assert_msg(!strcmp(expected, sanitized), "Expected: \"%s\", Found: \"%s\"", expected, sanitized);
|
|
1130
|
+ free(sanitized);
|
|
1131
|
+
|
|
1132
|
+ unsanitized = "relative" PATHSEP "shortname" PATHSEP "1";
|
|
1133
|
+ expected = "relative" PATHSEP "shortname" PATHSEP "1";
|
|
1134
|
+ expected_base = "1";
|
|
1135
|
+ sanitized = cli_sanitize_filepath(unsanitized, strlen(unsanitized), &sanitized_base);
|
|
1136
|
+ ck_assert(NULL != sanitized);
|
|
1137
|
+ ck_assert(NULL != sanitized_base);
|
|
1138
|
+ ck_assert_msg(!strcmp(expected, sanitized), "Expected: \"%s\", Found: \"%s\"", expected, sanitized);
|
|
1139
|
+ ck_assert_msg(!strcmp(expected_base, sanitized_base), "Expected: \"%s\", Found: \"%s\"", expected_base, sanitized_base);
|
|
1140
|
+ free(sanitized);
|
|
1141
|
+
|
|
1142
|
+ unsanitized = "relative" PATHSEP "noname" PATHSEP;
|
|
1143
|
+ expected = "relative" PATHSEP "noname" PATHSEP;
|
|
1144
|
+ sanitized = cli_sanitize_filepath(unsanitized, strlen(unsanitized), NULL);
|
|
1145
|
+ ck_assert(NULL != sanitized);
|
|
1146
|
+ ck_assert_msg(!strcmp(sanitized, "relative" PATHSEP "noname" PATHSEP), "sanitize_path: relative no name path test failed");
|
|
1147
|
+ ck_assert_msg(!strcmp(expected, sanitized), "Expected: \"%s\", Found: \"%s\"", expected, sanitized);
|
|
1148
|
+ free(sanitized);
|
|
1149
|
+
|
|
1150
|
+ unsanitized = "relative" PATHSEP "noname" PATHSEP;
|
|
1151
|
+ expected = "relative" PATHSEP "noname" PATHSEP;
|
|
1152
|
+ sanitized = cli_sanitize_filepath(unsanitized, strlen(unsanitized), &sanitized_base);
|
981
|
1153
|
ck_assert(NULL != sanitized);
|
982
|
|
- ck_assert_msg(!strcmp(sanitized, "relative" PATHSEP "shortname" PATHSEP "1"), "sanitize_path: relative short name path test failed");
|
|
1154
|
+ ck_assert(NULL == sanitized_base);
|
|
1155
|
+ ck_assert_msg(!strcmp(expected, sanitized), "Expected: \"%s\", Found: \"%s\"", expected, sanitized);
|
983
|
1156
|
free(sanitized);
|
984
|
1157
|
}
|
985
|
1158
|
END_TEST
|