Skip to content

Commit

Permalink
Bug 1141440: OPTION response for CORS requests to REST doesn't allow …
Browse files Browse the repository at this point in the history
…X-Bugzilla headers

- Fixed t/001compile.t error due to tr///r only for 5.14+
  • Loading branch information
dklawren committed Mar 11, 2015
1 parent cd00796 commit 64ad8e3
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions Bugzilla/WebService/Server/REST.pm
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,13 @@ sub response {
{ rpc => $self, result => \$result, response => $response });

# Access Control
my @allowed_headers = (qw(accept content-type origin x-requested-with),
map { tr/A-Z_/a-z\-/r } keys API_AUTH_HEADERS());
my @allowed_headers = qw(accept content-type origin x-requested-with);
foreach my $header (keys API_AUTH_HEADERS()) {
# We want to lowercase and replace _ with -
my $translated_header = $header;
$translated_header =~ tr/A-Z_/a-z\-/;
push(@allowed_headers, $translated_header);
}
$response->header("Access-Control-Allow-Origin", "*");
$response->header("Access-Control-Allow-Headers", join(', ', @allowed_headers));

Expand Down

0 comments on commit 64ad8e3

Please sign in to comment.