Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

There was a problem

You must be a member of this account.

This project is archived and is in readonly mode.

json encoding systax error

#4484

activesupport/lib/active_support/json/encoding.rb:107: syntax error, unexpected ':', expecting ')' (SyntaxError)

seems this is broken due to this commit.

commit c1d73270717f30498f8f4d55d6695509107c2834
Author: Jeremy Kemper jeremy@bitsweat.net

-          string = string.dup.force_encoding(::Encoding::BINARY) if string.respond_to?(:force_encodi
ng)
+          if string.respond_to?(:force_encoding)
+            string = string.encode(::Encoding::UTF_8, undef: :replace).force_encoding(::Encoding::BINARY)
+          end

$ ruby -v ruby 1.8.7 (2010-01-10 patchlevel 249) [x86_64-linux]

Reported by Juice · April 27th, 2010 @ 04:42 AM

State: committed
Milestone: none
Assigned to: Jeremy Kemper Jeremy Kemper
Importance: Low

Activity

  1. Ryan Bigg
    Ryan Bigg

    Please provide steps to reproduce this, most helpful would be a failing test case in the form of a patch. Please see the contributors guide.

    April 27th, 2010 @ 04:54 AM

  2. Will Sargent
    Will Sargent

    You can reproduce this bug by typing 'rails generate --help' at the console.

    /opt/local/lib/ruby/gems/1.8/gems/polyglot-0.3.1/lib/polyglot.rb:64:in polyglot_original_require': /Users/wsargent/.bundle/ruby/1.8/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/activesupport/lib/active_support/json/encoding.rb:107: syntax error, unexpected kUNDEF (SyntaxError) ...ncode(::Encoding::UTF_8, undef: :replace).force_encoding(::E...

                              ^
    from /opt/local/lib/ruby/gems/1.8/gems/polyglot-0.3.1/lib/polyglot.rb:64:in `require'
    from /Users/wsargent/.bundle/ruby/1.8/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/activesupport/lib/active_support/json.rb:2
    from /opt/local/lib/ruby/gems/1.8/gems/polyglot-0.3.1/lib/polyglot.rb:64:in `polyglot_original_require'
    from /opt/local/lib/ruby/gems/1.8/gems/polyglot-0.3.1/lib/polyglot.rb:64:in `require'
    from /Users/wsargent/.bundle/ruby/1.8/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/actionpack/lib/action_view/helpers/prototype_helper.rb:2
    from /Users/wsargent/.bundle/ruby/1.8/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/actionpack/lib/action_view/helpers/javascript_helper.rb:37
    from /opt/local/lib/ruby/gems/1.8/gems/polyglot-0.3.1/lib/polyglot.rb:64:in `polyglot_original_require'
    from /opt/local/lib/ruby/gems/1.8/gems/polyglot-0.3.1/lib/polyglot.rb:64:in `require'
    from /Users/wsargent/.bundle/ruby/1.8/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/actionpack/lib/action_view/helpers/url_helper.rb:1
    from /Users/wsargent/.bundle/ruby/1.8/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/actionpack/lib/action_view/helpers/form_tag_helper.rb:16
    from /opt/local/lib/ruby/gems/1.8/gems/polyglot-0.3.1/lib/polyglot.rb:64:in `polyglot_original_require'
    from /opt/local/lib/ruby/gems/1.8/gems/polyglot-0.3.1/lib/polyglot.rb:64:in `require'
    from /Users/wsargent/.bundle/ruby/1.8/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/actionpack/lib/action_view/helpers/form_helper.rb:4
    from /opt/local/lib/ruby/gems/1.8/gems/polyglot-0.3.1/lib/polyglot.rb:64:in `polyglot_original_require'
    from /opt/local/lib/ruby/gems/1.8/gems/polyglot-0.3.1/lib/polyglot.rb:64:in `require'
    from /Users/wsargent/.bundle/ruby/1.8/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/actionpack/lib/action_view/helpers/active_model_helper.rb:1
    from /Users/wsargent/.bundle/ruby/1.8/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/actionpack/lib/action_view/helpers.rb:39
    from /Users/wsargent/.bundle/ruby/1.8/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/actionpack/lib/action_view/base.rb:160
    from /Users/wsargent/.bundle/ruby/1.8/gems/haml-2.2.23/lib/haml/helpers/action_view_mods.rb:2
    from /opt/local/lib/ruby/gems/1.8/gems/polyglot-0.3.1/lib/polyglot.rb:64:in `polyglot_original_require'
    from /opt/local/lib/ruby/gems/1.8/gems/polyglot-0.3.1/lib/polyglot.rb:64:in `require'
    from /Users/wsargent/.bundle/ruby/1.8/gems/haml-2.2.23/lib/haml/helpers.rb:2
    from /opt/local/lib/ruby/gems/1.8/gems/polyglot-0.3.1/lib/polyglot.rb:64:in `polyglot_original_require'
    from /opt/local/lib/ruby/gems/1.8/gems/polyglot-0.3.1/lib/polyglot.rb:64:in `require'
    from /Users/wsargent/.bundle/ruby/1.8/gems/haml-2.2.23/lib/haml/engine.rb:1
    from /opt/local/lib/ruby/gems/1.8/gems/polyglot-0.3.1/lib/polyglot.rb:64:in `polyglot_original_require'
    from /opt/local/lib/ruby/gems/1.8/gems/polyglot-0.3.1/lib/polyglot.rb:64:in `require'
    from /Users/wsargent/.bundle/ruby/1.8/gems/haml-2.2.23/lib/haml.rb:40
    from /opt/local/lib/ruby/gems/1.8/gems/bundler-0.9.21/lib/bundler/runtime.rb:48:in `require'
    from /opt/local/lib/ruby/gems/1.8/gems/bundler-0.9.21/lib/bundler/runtime.rb:48:in `require'
    from /opt/local/lib/ruby/gems/1.8/gems/bundler-0.9.21/lib/bundler/runtime.rb:43:in `each'
    from /opt/local/lib/ruby/gems/1.8/gems/bundler-0.9.21/lib/bundler/runtime.rb:43:in `require'
    from /opt/local/lib/ruby/gems/1.8/gems/bundler-0.9.21/lib/bundler/runtime.rb:42:in `each'
    from /opt/local/lib/ruby/gems/1.8/gems/bundler-0.9.21/lib/bundler/runtime.rb:42:in `require'
    from /opt/local/lib/ruby/gems/1.8/gems/bundler-0.9.21/lib/bundler.rb:93:in `require'
    

    April 27th, 2010 @ 08:02 AM

  3. Will Sargent
    Will Sargent

    It should be:

    string = string.encode(::Encoding::UTF_8, :undef => :replace).force_encoding(::Encoding::BINARY)
    

    April 27th, 2010 @ 08:07 AM

  4. Ryan Bigg
    Ryan Bigg
    • State changed from new to needs-more-info

    Please formulate a patch and attach it to this ticket.

    April 27th, 2010 @ 08:35 AM

  5. James Sadler
  6. Ryan Bigg
    Ryan Bigg
    • State changed from needs-more-info to open

    Patch applies cleanly and fixes this for Ruby versions < 1.9.

    +1

    April 27th, 2010 @ 10:45 AM

  7. Santiago Pastorino
    Santiago Pastorino

    This was fixed by 1d63129eff1e25dd22e182cdef40ec61bf5dde88

    April 29th, 2010 @ 03:44 PM

  8. Ryan Bigg
    Ryan Bigg
    • State changed from open to committed

    Fixed by Xavier Noria in 1d63129eff1e25dd22e182cdef40ec61bf5dde88:

    use ordinary syntax for options to be well-formed in 1.8
    

    April 29th, 2010 @ 10:21 PM