Skip to content

Commit

Permalink
filterx: parse-csv: add empty delimiter handling
Browse files Browse the repository at this point in the history
Since the string-delimiters feature was added, the delimiter argument must be allowed to be set to empty to avoid parsing side effects.

Signed-off-by: shifter <[email protected]>
  • Loading branch information
bshifter committed Jul 9, 2024
1 parent aa466a2 commit 2543c79
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions modules/csvparser/filterx-func-parse-csv.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,9 @@ _extract_opts(FilterXFunctionParseCSV *self, FilterXFunctionArgs *args, GError *
value = filterx_function_args_get_named_literal_string(args, FILTERX_FUNC_PARSE_CSV_ARG_NAME_DELIMITER, &len, &exists);
if (exists)
{
if (len < 1)
if (len < 1 && !self->string_delimiters)
{
error_str = FILTERX_FUNC_PARSE_CSV_ARG_NAME_DELIMITER " can not be empty";
error_str = FILTERX_FUNC_PARSE_ERR_EMPTY_DELIMITER;
goto error;
}
if (!value)
Expand Down
5 changes: 5 additions & 0 deletions modules/csvparser/filterx-func-parse-csv.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@
FILTERX_FUNC_PARSE_CSV_ARG_NAME_DIALECT"=string, " \
FILTERX_FUNC_PARSE_CSV_ARG_NAME_STRIP_WHITESPACES"=boolean, " \
FILTERX_FUNC_PARSE_CSV_ARG_NAME_GREEDY"=boolean])"
#define FILTERX_FUNC_PARSE_ERR_EMPTY_DELIMITER "Either '" \
FILTERX_FUNC_PARSE_CSV_ARG_NAME_DELIMITER"' or '" \
FILTERX_FUNC_PARSE_CSV_ARG_NAME_STRING_DELIMITERS"' must be set, and '" \
FILTERX_FUNC_PARSE_CSV_ARG_NAME_DELIMITER"' cannot be empty if '" \
FILTERX_FUNC_PARSE_CSV_ARG_NAME_STRING_DELIMITERS"' is unset"

FilterXExpr *filterx_function_parse_csv_new(const gchar *function_name, FilterXFunctionArgs *args, GError **error);
gpointer filterx_function_construct_parse_csv(Plugin *self);
Expand Down

0 comments on commit 2543c79

Please sign in to comment.