@@ -62,7 +62,7 @@ static MCVariable *s_cgi_files; // ArrayRef
6262static MCVariable *s_cgi_get; // nativised StringRef
6363static MCVariable *s_cgi_get_raw; // StringRef
6464static MCVariable *s_cgi_get_binary; // DataRef
65- static MCVariable *s_cgi_cookie; // StringRef
65+ static MCVariable *s_cgi_cookie; // ArrayRef
6666
6767static bool s_cgi_processed_post = false ;
6868
@@ -923,6 +923,11 @@ static bool cgi_compute_get_var(void *p_context, MCVariable *p_var)
923923
924924 cgi_store_form_urlencoded (s_cgi_get, *t_query_data, true );
925925 }
926+ else
927+ {
928+ // Set the $_GET variable to the empty array
929+ s_cgi_get->setvalueref (kMCEmptyArray );
930+ }
926931
927932 return true ;
928933}
@@ -957,6 +962,11 @@ static bool cgi_compute_get_binary_var(void *p_context, MCVariable *p_var)
957962
958963 cgi_store_form_urlencoded (s_cgi_get_binary, *t_query_data, true );
959964 }
965+ else
966+ {
967+ // Set the $_GET_BINARY variable to the empty array
968+ s_cgi_get_binary->setvalueref (kMCEmptyArray );
969+ }
960970 return true ;
961971}
962972
@@ -1053,6 +1063,12 @@ static bool cgi_compute_post_variables()
10531063 cgi_store_form_multipart (t_stdin_handle);
10541064 MCS_close (t_stdin_handle);
10551065 }
1066+ else
1067+ {
1068+ // Set the $_POST and $_POST_BINARY variables to empty arrays
1069+ s_cgi_post->setvalueref (kMCEmptyArray );
1070+ s_cgi_post_binary->setvalueref (kMCEmptyArray );
1071+ }
10561072 return t_success;
10571073}
10581074
@@ -1419,8 +1435,12 @@ static bool cgi_compute_cookie_var(void *p_context, MCVariable *p_var)
14191435 cgi_store_cookie_urlencoded (s_cgi_cookie, *t_query_data, true );
14201436 }
14211437 else
1422- // returns true if nothing had to be computed
1423- return true ;
1438+ {
1439+ // There is no cookie data so set the variable to the empty array (it
1440+ // needs to be an array rather than the empty type because the rest of
1441+ // the CGI code assumes $_COOKIE holds an array).
1442+ s_cgi_cookie->setvalueref (kMCEmptyArray );
1443+ }
14241444
14251445 return t_success;
14261446}
0 commit comments