mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: crawler requests not tracked for non UTF-8 user agents
Non UTF-8 user_agent requests were bypassing logging due to PG always wanting UTF-8 strings. This adds some conversion to ensure we are always dealing with UTF-8
This commit is contained in:
@@ -117,7 +117,12 @@ class Middleware::RequestTracker
|
||||
}
|
||||
|
||||
if h[:is_crawler]
|
||||
h[:user_agent] = env['HTTP_USER_AGENT']
|
||||
user_agent = env['HTTP_USER_AGENT']
|
||||
if user_agent.encoding != Encoding::UTF_8
|
||||
user_agent = user_agent.encode("utf-8")
|
||||
user_agent.scrub!
|
||||
end
|
||||
h[:user_agent] = user_agent
|
||||
end
|
||||
|
||||
if cache = headers["X-Discourse-Cached"]
|
||||
|
Reference in New Issue
Block a user