Fix bug in `ActionController::Request#remote_ip` #4202

Merged
merged 1 commit into from Dec 29, 2011

2 participants

@dasch

If HTTP_X_FORWARDED_FOR only contains whitespace, don't try to extract a
list of IP addresses from it. Previously, calling #remote_ip when HTTP_X_FORWARDED_FOR was e.g. "" would cause "NoMethodError: undefined method strip for nil:NilClass".

@dasch dasch Make Request#remote_ip return nil when HTTP_X_FORWARDED_FOR is empty
If HTTP_X_FORWARDED_FOR only contains whitespace, don't try to extract a
list of IP addresses from it.
cd2136a
@tenderlove
Ruby on Rails member

@dasch this commit targets 2-3-stable, is this a backport? Does this bug exist in the other branches?

@dasch

@tenderlove we (Zendesk) experienced it on 2.3, and I wrote the patch directly on 2-3-stable. I can check if the bug is also present in latest stable tomorrow.

@tenderlove
Ruby on Rails member

@dasch please do. I'd rather apply this to master and backport than only commit to the release branch.

@dasch

@tenderlove it seems this stuff has been moved to Rack in 3.0, Rails simply delegates to Rack::Request.

This passes on master:

    request = stub_request 'HTTP_X_FORWARDED_FOR' => ''
    assert_nil request.remote_ip

I think this is just a 2.3 issue.

@tenderlove
Ruby on Rails member

Okay. I'll merge this to 2-3-stable, but please note that we have no plans of releasing another version of 2.3.

@tenderlove tenderlove merged commit 2eb197e into rails:2-3-stable Dec 29, 2011
@dasch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment