Comparison

plugins/mod_http.lua @ 13139:5d5869f14c4d 0.12

mod_http: Fix error if 'access_control_allow_origins' is set Because it changes the type of the 'opt_origins' variable from util.set to the internal _items table so next time an http app is added an error "attempt to call a nil value (method 'empty')" is triggered. The value is not used anywhere else. Noticed when reviewing uses of the '_items' set property. Not reported by any users, implying this setting is rarely used.
author Kim Alvefur <zash@zash.se>
date Sat, 10 Jun 2023 12:33:58 +0200
parent 12923:419e55abd285
child 13141:451cb119026e
comparison
equal deleted inserted replaced
13138:0b0cefce6e42 13139:5d5869f14c4d
147 local app_methods = opt_methods; 147 local app_methods = opt_methods;
148 local app_headers = opt_headers; 148 local app_headers = opt_headers;
149 local app_credentials = opt_credentials; 149 local app_credentials = opt_credentials;
150 local app_origins; 150 local app_origins;
151 if opt_origins and not (opt_origins:empty() or opt_origins:contains("*")) then 151 if opt_origins and not (opt_origins:empty() or opt_origins:contains("*")) then
152 opt_origins = opt_origins._items; 152 app_origins = opt_origins._items;
153 end 153 end
154 154
155 local function cors_handler(event_data) 155 local function cors_handler(event_data)
156 local request, response = event_data.request, event_data.response; 156 local request, response = event_data.request, event_data.response;
157 apply_cors_headers(response, app_methods, app_headers, opt_max_age, app_credentials, app_origins, request.headers.origin); 157 apply_cors_headers(response, app_methods, app_headers, opt_max_age, app_credentials, app_origins, request.headers.origin);