Skip to content

Commit

Permalink
quirks: don't allow single quotes for values
Browse files Browse the repository at this point in the history
At least not opening single quotes, same as the double quotes we already have.
Add the tests for both.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
  • Loading branch information
whot committed Aug 13, 2018
1 parent 41d4ab3 commit 11a5f91
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/quirks.c
Expand Up @@ -762,7 +762,7 @@ parse_value_line(struct quirks_context *ctx, struct section *s, const char *line
goto out;

/* Whatever the value is, it's not supposed to be in quotes */
if (value[0] == '"')
if (value[0] == '"' || value[0] == '\'')
goto out;

if (strneq(key, "Match", 5))
Expand Down
42 changes: 42 additions & 0 deletions test/test-quirks.c
Expand Up @@ -420,6 +420,46 @@ START_TEST(quirks_parse_comment_empty)
}
END_TEST

START_TEST(quirks_parse_string_quotes_single)
{
struct quirks_context *ctx;
const char quirks_file[] =
"[Section name]\n"
"MatchUdevType=mouse\n"
"AttrKeyboardIntegration='internal'\n";
struct data_dir dd = make_data_dir(quirks_file);

ctx = quirks_init_subsystem(dd.dirname,
NULL,
log_handler,
NULL,
QLOG_CUSTOM_LOG_PRIORITIES);
ck_assert(ctx == NULL);
quirks_context_unref(ctx);
cleanup_data_dir(dd);
}
END_TEST

START_TEST(quirks_parse_string_quotes_double)
{
struct quirks_context *ctx;
const char quirks_file[] =
"[Section name]\n"
"MatchUdevType=mouse\n"
"AttrKeyboardIntegration=\"internal\"\n";
struct data_dir dd = make_data_dir(quirks_file);

ctx = quirks_init_subsystem(dd.dirname,
NULL,
log_handler,
NULL,
QLOG_CUSTOM_LOG_PRIORITIES);
ck_assert(ctx == NULL);
quirks_context_unref(ctx);
cleanup_data_dir(dd);
}
END_TEST

START_TEST(quirks_parse_bustype)
{
struct quirks_context *ctx;
Expand Down Expand Up @@ -1369,6 +1409,8 @@ TEST_COLLECTION(quirks)
litest_add_deviceless("quirks:parsing", quirks_parse_error_model_not_one);
litest_add_deviceless("quirks:parsing", quirks_parse_comment_inline);
litest_add_deviceless("quirks:parsing", quirks_parse_comment_empty);
litest_add_deviceless("quirks:parsing", quirks_parse_string_quotes_single);
litest_add_deviceless("quirks:parsing", quirks_parse_string_quotes_double);

litest_add_deviceless("quirks:parsing", quirks_parse_bustype);
litest_add_deviceless("quirks:parsing", quirks_parse_bustype_invalid);
Expand Down

0 comments on commit 11a5f91

Please sign in to comment.