Skip to content

Commit

Permalink
Change: Escape minus in regular expressions for pcre 2 compatibility
Browse files Browse the repository at this point in the history
Escape all minus symbols in regular expressions to ensure the
expressions are compatible with pcre 2.

(cherry picked from commit 912350f)
  • Loading branch information
bjoernricks authored and mergify[bot] committed Oct 12, 2022
1 parent 9a19649 commit fa9178e
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/manage_configs.c
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ should_sync_config_from_path (const char *path, gboolean rebuild,

split = g_regex_split_simple
(/* Full-and-Fast--daba56c8-73ec-11df-a475-002264764cea.xml */
"^.*([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12}).xml$",
"^.*([0-9a-f]{8})\\-([0-9a-f]{4})\\-([0-9a-f]{4})\\-([0-9a-f]{4})\\-([0-9a-f]{12}).xml$",
path, 0, 0);

if (split == NULL || g_strv_length (split) != 7)
Expand Down
2 changes: 1 addition & 1 deletion src/manage_port_lists.c
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ should_sync_port_list_from_path (const char *path, gboolean rebuild,

split = g_regex_split_simple
(/* Full-and-Fast--daba56c8-73ec-11df-a475-002264764cea.xml */
"^.*([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12}).xml$",
"^.*([0-9a-f]{8})\\-([0-9a-f]{4})\\-([0-9a-f]{4})\\-([0-9a-f]{4})\\-([0-9a-f]{12}).xml$",
path, 0, 0);

if (split == NULL || g_strv_length (split) != 7)
Expand Down
2 changes: 1 addition & 1 deletion src/manage_report_formats.c
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ should_sync_report_format_from_path (const char *path,

split = g_regex_split_simple
(/* Full-and-Fast--daba56c8-73ec-11df-a475-002264764cea.xml */
"^.*([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12}).xml$",
"^.*([0-9a-f]{8})\\-([0-9a-f]{4})\\-([0-9a-f]{4})\\-([0-9a-f]{4})\\-([0-9a-f]{12}).xml$",
path, 0, 0);

if (split == NULL || g_strv_length (split) != 7)
Expand Down
8 changes: 4 additions & 4 deletions src/manage_sql.c
Original file line number Diff line number Diff line change
Expand Up @@ -6997,7 +6997,7 @@ validate_tippingpoint_data (alert_method_t method, const gchar *name,

if (strcmp (name, "tp_sms_hostname") == 0)
{
if (g_regex_match_simple ("^[0-9A-Za-z][0-9A-Za-z.-]*$",
if (g_regex_match_simple ("^[0-9A-Za-z][0-9A-Za-z.\\-]*$",
*data, 0, 0)
== FALSE)
{
Expand Down Expand Up @@ -49757,8 +49757,8 @@ modify_setting (const gchar *uuid, const gchar *name,
*/
languages_regex
= g_regex_new ("^(Browser Language|"
"([a-z]{2,3})(_[A-Z]{2})?(@[[:alnum:]_-]+)?"
"(:([a-z]{2,3})(_[A-Z]{2})?(@[[:alnum:]_-]+)?)*)$",
"([a-z]{2,3})(_[A-Z]{2})?(@[[:alnum:]_\\-]+)?"
"(:([a-z]{2,3})(_[A-Z]{2})?(@[[:alnum:]_\\-]+)?)*)$",
0, 0, NULL);
match = g_regex_match (languages_regex, value, 0, NULL);
g_regex_unref (languages_regex);
Expand Down Expand Up @@ -50326,7 +50326,7 @@ setting_verify (const gchar *uuid, const gchar *value, const gchar *user)
if (strcmp (uuid, SETTING_UUID_LSC_DEB_MAINTAINER) == 0)
{
if (g_regex_match_simple
("^([[:alnum:]-_]*@[[:alnum:]-_][[:alnum:]-_.]*)?$",
("^([[:alnum:]\\-_]*@[[:alnum:]\\-_][[:alnum:]\\-_.]*)?$",
value, 0, 0) == FALSE)
return 1;
}
Expand Down
2 changes: 1 addition & 1 deletion src/manage_sql_report_formats.c
Original file line number Diff line number Diff line change
Expand Up @@ -2472,7 +2472,7 @@ validate_param_value (report_format_t report_format,
case REPORT_FORMAT_PARAM_TYPE_REPORT_FORMAT_LIST:
{
if (g_regex_match_simple
("^(?:[[:alnum:]-_]+)?(?:,(?:[[:alnum:]-_])+)*$", value, 0, 0)
("^(?:[[:alnum:]\\-_]+)?(?:,(?:[[:alnum:]\\-_])+)*$", value, 0, 0)
== FALSE)
return 1;
else
Expand Down
2 changes: 1 addition & 1 deletion src/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ parse_iso_time_tz (const char *text_time, const char *fallback_tz)
epoch_time = 0;

if (regex == NULL)
regex = g_regex_new ("^([0-9]{4}-[0-9]{2}-[0-9]{2})"
regex = g_regex_new ("^([0-9]{4}\\-[0-9]{2}\\-[0-9]{2})"
"[T ]([0-9]{2}:[0-9]{2})"
"(:[0-9]{2})?(?:\\.[0-9]+)?"
"(Z|[+-][0-9]{2}:?[0-9]{2})?$",
Expand Down

0 comments on commit fa9178e

Please sign in to comment.