Encoding::CompatibilityError when utf8 project dir and utf8 url #13518

Closed
sih4sing5hong5 opened this Issue Dec 28, 2013 · 4 comments

Comments

Projects
None yet
3 participants
@sih4sing5hong5

I name the rails project dir with non-ASCII chars.
It works with any ascii URL.
When URL contains non-ASCII chars,
throw this following CompatibilityError.
It appears both utf8 rails dir name and utf8 url.

[2013-12-28 22:25:07] ERROR Encoding::CompatibilityError: incompatible character encodings: UTF-8 and ASCII-8BIT
/usr/local/lib/ruby/gems/2.1.0/gems/actionpack-4.0.0/lib/action_dispatch/middleware/static.rb:17:in join' /usr/local/lib/ruby/gems/2.1.0/gems/actionpack-4.0.0/lib/action_dispatch/middleware/static.rb:17:inmatch?'
/usr/local/lib/ruby/gems/2.1.0/gems/actionpack-4.0.0/lib/action_dispatch/middleware/static.rb:59:in call' /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.0.0/lib/rails/engine.rb:512:incall'
/usr/local/lib/ruby/gems/2.1.0/gems/railties-4.0.0/lib/rails/application.rb:98:in call' /usr/local/lib/ruby/gems/2.1.0/gems/rack-1.5.2/lib/rack/lock.rb:18:incall'
/usr/local/lib/ruby/gems/2.1.0/gems/rack-1.5.2/lib/rack/content_length.rb:15:in call' /usr/local/lib/ruby/gems/2.1.0/gems/rack-1.5.2/lib/rack/handler/webrick.rb:61:inservice'
/usr/local/lib/ruby/2.1.0/webrick/httpserver.rb:139:in service' /usr/local/lib/ruby/2.1.0/webrick/httpserver.rb:95:inrun'
/usr/local/lib/ruby/2.1.0/webrick/server.rb:296:in `block in start_thread'

@robin850

This comment has been minimized.

Show comment Hide comment
@robin850

robin850 Dec 29, 2013

Member

Hello @sih4sing5hong5,

II may be totally wrong but I think this could be resolved with #13386, could you try to put :

gem 'rails', github: 'rails/rails'

in your Gemfile and run bundle install then retry please ?

Member

robin850 commented Dec 29, 2013

Hello @sih4sing5hong5,

II may be totally wrong but I think this could be resolved with #13386, could you try to put :

gem 'rails', github: 'rails/rails'

in your Gemfile and run bundle install then retry please ?

@pixeltrix

This comment has been minimized.

Show comment Hide comment
@pixeltrix

pixeltrix Dec 29, 2013

Owner

@robin850 I don't think it will since this is in a 4.0 app and the to_param code was added for 4.1

Owner

pixeltrix commented Dec 29, 2013

@robin850 I don't think it will since this is in a 4.0 app and the to_param code was added for 4.1

@ghost ghost assigned pixeltrix Dec 29, 2013

@robin850

This comment has been minimized.

Show comment Hide comment
@robin850

robin850 Dec 29, 2013

Member

@pixeltrix : Ah, good catch!

Member

robin850 commented Dec 29, 2013

@pixeltrix : Ah, good catch!

@sih4sing5hong5

This comment has been minimized.

Show comment Hide comment
@sih4sing5hong5

sih4sing5hong5 Dec 29, 2013

It doesn't still work.
[2013-12-29 22:17:04] ERROR Encoding::CompatibilityError: incompatible character encodings: UTF-8 and ASCII-8BIT
/home/Ihc/.bundler/ruby/2.1.0/rails-126dc47665c6/actionpack/lib/action_dispatch/middleware/static.rb:16:in join' /home/Ihc/.bundler/ruby/2.1.0/rails-126dc47665c6/actionpack/lib/action_dispatch/middleware/static.rb:16:inmatch?'
/home/Ihc/.bundler/ruby/2.1.0/rails-126dc47665c6/actionpack/lib/action_dispatch/middleware/static.rb:58:in call' /usr/local/lib/ruby/gems/2.1.0/gems/rack-1.5.2/lib/rack/sendfile.rb:112:incall'
/home/Ihc/.bundler/ruby/2.1.0/rails-126dc47665c6/railties/lib/rails/engine.rb:515:in call' /home/Ihc/.bundler/ruby/2.1.0/rails-126dc47665c6/railties/lib/rails/application.rb:142:incall'
/usr/local/lib/ruby/gems/2.1.0/gems/rack-1.5.2/lib/rack/lock.rb:17:in call' /usr/local/lib/ruby/gems/2.1.0/gems/rack-1.5.2/lib/rack/content_length.rb:14:incall'
/usr/local/lib/ruby/gems/2.1.0/gems/rack-1.5.2/lib/rack/handler/webrick.rb:60:in service' /usr/local/lib/ruby/2.1.0/webrick/httpserver.rb:138:inservice'
/usr/local/lib/ruby/2.1.0/webrick/httpserver.rb:94:in run' /usr/local/lib/ruby/2.1.0/webrick/server.rb:295:inblock in start_thread'

It doesn't still work.
[2013-12-29 22:17:04] ERROR Encoding::CompatibilityError: incompatible character encodings: UTF-8 and ASCII-8BIT
/home/Ihc/.bundler/ruby/2.1.0/rails-126dc47665c6/actionpack/lib/action_dispatch/middleware/static.rb:16:in join' /home/Ihc/.bundler/ruby/2.1.0/rails-126dc47665c6/actionpack/lib/action_dispatch/middleware/static.rb:16:inmatch?'
/home/Ihc/.bundler/ruby/2.1.0/rails-126dc47665c6/actionpack/lib/action_dispatch/middleware/static.rb:58:in call' /usr/local/lib/ruby/gems/2.1.0/gems/rack-1.5.2/lib/rack/sendfile.rb:112:incall'
/home/Ihc/.bundler/ruby/2.1.0/rails-126dc47665c6/railties/lib/rails/engine.rb:515:in call' /home/Ihc/.bundler/ruby/2.1.0/rails-126dc47665c6/railties/lib/rails/application.rb:142:incall'
/usr/local/lib/ruby/gems/2.1.0/gems/rack-1.5.2/lib/rack/lock.rb:17:in call' /usr/local/lib/ruby/gems/2.1.0/gems/rack-1.5.2/lib/rack/content_length.rb:14:incall'
/usr/local/lib/ruby/gems/2.1.0/gems/rack-1.5.2/lib/rack/handler/webrick.rb:60:in service' /usr/local/lib/ruby/2.1.0/webrick/httpserver.rb:138:inservice'
/usr/local/lib/ruby/2.1.0/webrick/httpserver.rb:94:in run' /usr/local/lib/ruby/2.1.0/webrick/server.rb:295:inblock in start_thread'

@pixeltrix pixeltrix closed this in 436ed51 Dec 29, 2013

pixeltrix added a commit that referenced this issue Dec 29, 2013

Fix Encoding::CompatibilityError when public path is UTF-8
In #5337 we forced the path encoding to ASCII-8BIT to prevent static
file handling from blowing up before an application has had chance to
deal with possibly invalid urls. However this has a negative side
effect of making it an incompatible encoding if the application's
public path has UTF-8 characters in it.

To work around the problem we check to see if the path has a valid
encoding once it has been unescaped. If it is not valid then we can
return early since it will not match any file anyway.

Fixes #13518

(cherry picked from commit 436ed51)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment