Browse Source

Do not error on empty URI parameters.

When a URI parameter is completely empty (e.g., ?& or &&), ignore it
without erroring out.
master
Damien Goutte-Gattat 3 months ago
parent
commit
54b1ecd11c
  1. 4
      src/secretcfg.c
  2. 6
      tests/t-parseuri.c

4
src/secretcfg.c

@ -198,8 +198,8 @@ parse_parameter(const char **uri, gfsec_share_t *share)
if ( **uri == '?' || **uri == '&' )
*uri += 1; /* Skip initial delimiter. */
if ( **uri == '\0' )
return 0; /* Silently ignore terminal delimiter. */
if ( **uri == '\0' || **uri == '&' )
return 0; /* Silently ignore empty parameter. */
amp = strchrnul(*uri, '&');
if ( ! (eq = strchr(*uri, '=')) || amp < eq )

6
tests/t-parseuri.c

@ -72,6 +72,12 @@ struct test tests[] = {
{ "file:///path/to/share.123?param1=val&share=no&param3=val3",
0, GFSEC_SCHEME_FILE, "", "/path/to/share.123", 0, 1 },
/* Empty parameters. */
{ "file:///path/to/share.123?param1=val&&share=124",
0, GFSEC_SCHEME_FILE, "", "/path/to/share.123", 124, 0 },
{ "file:///path/to/share.123?&share=124&",
0, GFSEC_SCHEME_FILE, "", "/path/to/share.123", 124, 0 },
/* Parameter with no value. */
{ "file:///path/to/share.123?param", GFSEC_ERR_CONFIG_INVALID_URI },
{ "file:///path/to/share.123?param1=val1&param2",

Loading…
Cancel
Save