@@ -4934,36 +4934,30 @@ conninfo_uri_parse_params(char *params,
4934
4934
{
4935
4935
printfPQExpBuffer (errorMessage ,
4936
4936
libpq_gettext ("extra key/value separator \"=\" in URI query parameter: \"%s\"\n" ),
4937
- params );
4937
+ keyword );
4938
4938
return false;
4939
4939
}
4940
4940
/* Cut off keyword, advance to value */
4941
- * p = '\0' ;
4942
- value = ++ p ;
4941
+ * p ++ = '\0' ;
4942
+ value = p ;
4943
4943
}
4944
4944
else if (* p == '&' || * p == '\0' )
4945
4945
{
4946
- char prevchar ;
4947
-
4948
- /* Cut off value, remember old value */
4949
- prevchar = * p ;
4950
- * p = '\0' ;
4951
-
4946
+ /*
4947
+ * If not at the end, cut off value and advance; leave p
4948
+ * pointing to start of the next parameter, if any.
4949
+ */
4950
+ if ( * p ! = '\0' )
4951
+ * p ++ = '\0' ;
4952
4952
/* Was there '=' at all? */
4953
4953
if (value == NULL )
4954
4954
{
4955
4955
printfPQExpBuffer (errorMessage ,
4956
4956
libpq_gettext ("missing key/value separator \"=\" in URI query parameter: \"%s\"\n" ),
4957
- params );
4957
+ keyword );
4958
4958
return false;
4959
4959
}
4960
-
4961
- /*
4962
- * If not at the end, advance; now pointing to start of the
4963
- * next parameter, if any.
4964
- */
4965
- if (prevchar != '\0' )
4966
- ++ p ;
4960
+ /* Got keyword and value, go process them. */
4967
4961
break ;
4968
4962
}
4969
4963
else
@@ -5007,38 +5001,27 @@ conninfo_uri_parse_params(char *params,
5007
5001
if (!conninfo_storeval (connOptions , keyword , value ,
5008
5002
errorMessage , true, false))
5009
5003
{
5010
- /*
5011
- * Check if there was a hard error when decoding or storing the
5012
- * option.
5013
- */
5014
- if (errorMessage -> len != 0 )
5015
- {
5016
- if (malloced )
5017
- {
5018
- free (keyword );
5019
- free (value );
5020
- }
5021
- return false;
5022
- }
5023
-
5024
- printfPQExpBuffer (errorMessage ,
5025
- libpq_gettext (
5026
- "invalid URI query parameter: \"%s\"\n" ),
5027
- keyword );
5004
+ /* Insert generic message if conninfo_storeval didn't give one. */
5005
+ if (errorMessage -> len == 0 )
5006
+ printfPQExpBuffer (errorMessage ,
5007
+ libpq_gettext ("invalid URI query parameter: \"%s\"\n" ),
5008
+ keyword );
5009
+ /* And fail. */
5028
5010
if (malloced )
5029
5011
{
5030
5012
free (keyword );
5031
5013
free (value );
5032
5014
}
5033
5015
return false;
5034
5016
}
5017
+
5035
5018
if (malloced )
5036
5019
{
5037
5020
free (keyword );
5038
5021
free (value );
5039
5022
}
5040
5023
5041
- /* Proceed to next key=value pair */
5024
+ /* Proceed to next key=value pair, if any */
5042
5025
params = p ;
5043
5026
}
5044
5027
0 commit comments