@@ -123,6 +123,13 @@ count_dots (const char *s)
123
123
return n ;
124
124
}
125
125
126
+ static char *
127
+ lowercase_str_new (const char * key )
128
+ {
129
+ char * ret = bson_strdup (key );
130
+ mongoc_lowercase (key , ret );
131
+ return ret ;
132
+ }
126
133
127
134
/* at least one character, and does not start with dot */
128
135
static bool
@@ -2573,6 +2580,7 @@ _mongoc_uri_set_option_as_int32_with_error (mongoc_uri_t *uri,
2573
2580
const char * option ;
2574
2581
const bson_t * options ;
2575
2582
bson_iter_t iter ;
2583
+ char * option_lowercase = NULL ;
2576
2584
2577
2585
option = mongoc_uri_canonicalize_option (option_orig );
2578
2586
/* Server Discovery and Monitoring Spec: "the driver MUST NOT permit users
@@ -2611,14 +2619,16 @@ _mongoc_uri_set_option_as_int32_with_error (mongoc_uri_t *uri,
2611
2619
return false;
2612
2620
}
2613
2621
}
2614
-
2615
- if (!bson_append_int32 (& uri -> options , option , -1 , value )) {
2622
+ option_lowercase = lowercase_str_new (option );
2623
+ if (!bson_append_int32 (& uri -> options , option_lowercase , -1 , value )) {
2624
+ bson_free (option_lowercase );
2616
2625
MONGOC_URI_ERROR (
2617
2626
error , "Failed to set URI option \"%s\" to %d" , option_orig , value );
2618
2627
2619
2628
return false;
2620
2629
}
2621
2630
2631
+ bson_free (option_lowercase );
2622
2632
return true;
2623
2633
}
2624
2634
@@ -2645,6 +2655,7 @@ _mongoc_uri_set_option_as_int32 (mongoc_uri_t *uri,
2645
2655
const char * option ;
2646
2656
const bson_t * options ;
2647
2657
bson_iter_t iter ;
2658
+ char * option_lowercase = NULL ;
2648
2659
2649
2660
option = mongoc_uri_canonicalize_option (option_orig );
2650
2661
if ((options = mongoc_uri_get_options (uri )) &&
@@ -2657,7 +2668,9 @@ _mongoc_uri_set_option_as_int32 (mongoc_uri_t *uri,
2657
2668
}
2658
2669
}
2659
2670
2660
- bson_append_int32 (& uri -> options , option , -1 , value );
2671
+ option_lowercase = lowercase_str_new (option );
2672
+ bson_append_int32 (& uri -> options , option_lowercase , -1 , value );
2673
+ bson_free (option_lowercase );
2661
2674
return true;
2662
2675
}
2663
2676
@@ -2795,6 +2808,7 @@ _mongoc_uri_set_option_as_int64_with_error (mongoc_uri_t *uri,
2795
2808
const char * option ;
2796
2809
const bson_t * options ;
2797
2810
bson_iter_t iter ;
2811
+ char * option_lowercase = NULL ;
2798
2812
2799
2813
option = mongoc_uri_canonicalize_option (option_orig );
2800
2814
@@ -2814,15 +2828,17 @@ _mongoc_uri_set_option_as_int64_with_error (mongoc_uri_t *uri,
2814
2828
}
2815
2829
}
2816
2830
2817
- if (!bson_append_int64 (& uri -> options , option , -1 , value )) {
2831
+ option_lowercase = lowercase_str_new (option );
2832
+ if (!bson_append_int64 (& uri -> options , option_lowercase , -1 , value )) {
2833
+ bson_free (option_lowercase );
2818
2834
MONGOC_URI_ERROR (error ,
2819
2835
"Failed to set URI option \"%s\" to %" PRId64 ,
2820
2836
option_orig ,
2821
2837
value );
2822
2838
2823
2839
return false;
2824
2840
}
2825
-
2841
+ bson_free ( option_lowercase );
2826
2842
return true;
2827
2843
}
2828
2844
@@ -2893,6 +2909,7 @@ mongoc_uri_set_option_as_bool (mongoc_uri_t *uri,
2893
2909
bool value )
2894
2910
{
2895
2911
const char * option ;
2912
+ char * option_lowercase ;
2896
2913
const bson_t * options ;
2897
2914
bson_iter_t iter ;
2898
2915
@@ -2912,8 +2929,9 @@ mongoc_uri_set_option_as_bool (mongoc_uri_t *uri,
2912
2929
return false;
2913
2930
}
2914
2931
}
2915
-
2916
- bson_append_bool (& uri -> options , option , -1 , value );
2932
+ option_lowercase = lowercase_str_new (option );
2933
+ bson_append_bool (& uri -> options , option_lowercase , -1 , value );
2934
+ bson_free (option_lowercase );
2917
2935
return true;
2918
2936
}
2919
2937
@@ -2989,6 +3007,7 @@ mongoc_uri_set_option_as_utf8 (mongoc_uri_t *uri,
2989
3007
{
2990
3008
const char * option ;
2991
3009
size_t len ;
3010
+ char * option_lowercase = NULL ;
2992
3011
2993
3012
option = mongoc_uri_canonicalize_option (option_orig );
2994
3013
BSON_ASSERT (option );
@@ -3005,7 +3024,10 @@ mongoc_uri_set_option_as_utf8 (mongoc_uri_t *uri,
3005
3024
if (!bson_strcasecmp (option , MONGOC_URI_APPNAME )) {
3006
3025
return mongoc_uri_set_appname (uri , value );
3007
3026
} else {
3008
- mongoc_uri_bson_append_or_replace_key (& uri -> options , option , value );
3027
+ option_lowercase = lowercase_str_new (option );
3028
+ mongoc_uri_bson_append_or_replace_key (
3029
+ & uri -> options , option_lowercase , value );
3030
+ bson_free (option_lowercase );
3009
3031
}
3010
3032
3011
3033
return true;
0 commit comments