Commit 67f6ebd913c3b64ae82f47ce6835ab54f8291eaf
1 parent
4e97f113
Exists in
master
and in
22 other branches
content-viewer-controller: user_is_a_bot consider possible empty user_agent
Showing
1 changed file
with
6 additions
and
4 deletions
Show diff stats
app/controllers/public/content_viewer_controller.rb
| @@ -159,10 +159,12 @@ class ContentViewerController < ApplicationController | @@ -159,10 +159,12 @@ class ContentViewerController < ApplicationController | ||
| 159 | helper_method :pass_without_comment_captcha? | 159 | helper_method :pass_without_comment_captcha? |
| 160 | 160 | ||
| 161 | def user_is_a_bot? | 161 | def user_is_a_bot? |
| 162 | - request.env["HTTP_USER_AGENT"].match(/bot/) || | ||
| 163 | - request.env["HTTP_USER_AGENT"].match(/spider/) || | ||
| 164 | - request.env["HTTP_USER_AGENT"].match(/crawler/) || | ||
| 165 | - request.env["HTTP_USER_AGENT"].match(/\(.*https?:\/\/.*\)/) | 162 | + user_agent= request.env["HTTP_USER_AGENT"] |
| 163 | + user_agent.blank? || | ||
| 164 | + user_agent.match(/bot/) || | ||
| 165 | + user_agent.match(/spider/) || | ||
| 166 | + user_agent.match(/crawler/) || | ||
| 167 | + user_agent.match(/\(.*https?:\/\/.*\)/) | ||
| 166 | end | 168 | end |
| 167 | 169 | ||
| 168 | end | 170 | end |