Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/plugins_types/date.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ lyplg_type_store_date(const struct ly_ctx *ctx, const struct lysc_type *type, co
if (!(options & LYPLG_TYPE_STORE_ONLY)) {
/* validate value */
ret = lyplg_type_validate_patterns(ctx, ((struct lysc_type_str *)type)->patterns, value, value_size, err);
LY_CHECK_RET(ret);
LY_CHECK_GOTO(ret, cleanup);
}

if (val) {
Expand Down
2 changes: 1 addition & 1 deletion src/plugins_types/date_and_time.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ lyplg_type_store_date_and_time(const struct ly_ctx *ctx, const struct lysc_type
if (!(options & LYPLG_TYPE_STORE_ONLY)) {
/* validate value */
ret = lyplg_type_validate_patterns(ctx, ((struct lysc_type_str *)type)->patterns, value, value_size, err);
LY_CHECK_RET(ret);
LY_CHECK_GOTO(ret, cleanup);
}

/* convert to UNIX time and fractions of second */
Expand Down
2 changes: 1 addition & 1 deletion src/plugins_types/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ lyplg_type_store_time(const struct ly_ctx *ctx, const struct lysc_type *type, co
if (!(options & LYPLG_TYPE_STORE_ONLY)) {
/* validate value */
ret = lyplg_type_validate_patterns(ctx, ((struct lysc_type_str *)type)->patterns, value, value_size, err);
LY_CHECK_RET(ret);
LY_CHECK_GOTO(ret, cleanup);
}

if (val) {
Expand Down
15 changes: 15 additions & 0 deletions tests/utests/types/yang_types.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,22 @@ test_data_xml(void **state)
"(\\.[0-9]+)?(Z|[\\+\\-]((1[0-3]|0[0-9]):([0-5][0-9])|14:00))?\".",
"/a:l", 1);

/* invalid value in a dynamic buffer (entity reference) */
TEST_ERROR_XML("a", "l", "2005-05-31T23:15:15&", LY_EVALID);
CHECK_LOG_CTX("Unsatisfied pattern - \"2005-05-31T23:15:15&\" does not match "
"\"[0-9]{4}-(1[0-2]|0[1-9])-(0[1-9]|[1-2][0-9]|3[0-1])T(0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]:([0-5][0-9]|60)"
"(\\.[0-9]+)?(Z|[\\+\\-]((1[0-3]|0[0-9]):([0-5][0-9])|14:00))?\".",
"/a:l", 1);

/* date */
TEST_SUCCESS_XML("a", "l2", "2005-05-31-01:00", STRING, "2005-05-30-02:00");
#ifndef _WIN32
TEST_SUCCESS_XML("a", "l2", "1950-01-01-02:00", STRING, "1950-01-01-02:00");
#endif
TEST_ERROR_XML("a", "l2", "2005-05-31&", LY_EVALID);
CHECK_LOG_CTX("Unsatisfied pattern - \"2005-05-31&\" does not match "
"\"[0-9]{4}-(1[0-2]|0[1-9])-(0[1-9]|[1-2][0-9]|3[0-1])(Z|[\\+\\-]((1[0-3]|0[0-9]):([0-5][0-9])|14:00))?\".",
"/a:l2", 1);

/* date-no-zone */
TEST_SUCCESS_XML("a", "l2nz", "2005-05-31", STRING, "2005-05-31");
Expand All @@ -149,6 +160,10 @@ test_data_xml(void **state)
/* time */
TEST_SUCCESS_XML("a", "l4", "23:15:15-01:00", STRING, "22:15:15-02:00");
TEST_SUCCESS_XML("a", "l4", "00:59:59.001-02:00", STRING, "00:59:59.001-02:00");
TEST_ERROR_XML("a", "l4", "23:15:15&", LY_EVALID);
CHECK_LOG_CTX("Unsatisfied pattern - \"23:15:15&\" does not match "
"\"(0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]:([0-5][0-9]|60)(\\.[0-9]+)?(Z|[\\+\\-]((1[0-3]|0[0-9]):([0-5][0-9])|14:00))?\".",
"/a:l4", 1);

/* time-no-zone */
TEST_SUCCESS_XML("a", "l4nz", "23:15:15", STRING, "23:15:15");
Expand Down
Loading