FIX: ensures slug and id are not arrays (#8495)

If for some reason an URL was create in this format:

```
?slug[]=foo&slug[]=bar
```

This would have create an exception of this kind:

```
NoMethodError (undefined method `tr' for ["foo", "bar"]:Array
Did you mean?  try)
```
This commit is contained in:
Joffrey JAFFEUX 2019-12-10 09:28:51 +01:00 committed by GitHub
parent f5396e2700
commit 47731175f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -790,6 +790,9 @@ class ApplicationController < ActionController::Base
@title = opts[:title] || I18n.t("page_not_found.title")
@group = opts[:group]
@hide_search = true if SiteSetting.login_required
params[:slug] = params[:slug].first if params[:slug].kind_of?(Array)
params[:id] = params[:id].first if params[:id].kind_of?(Array)
@slug = (params[:slug].presence || params[:id].presence || "").tr('-', ' ')
render_to_string status: opts[:status], layout: opts[:layout], formats: [:html], template: '/exceptions/not_found'