This project is archived and is in readonly mode.

#4484 ✓committed
Juice

json encoding systax error

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

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]

Comments and changes to this ticket

  • Ryan Bigg

    Ryan Bigg April 27th, 2010 @ 04:54 AM

    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.

  • Will Sargent

    Will Sargent April 27th, 2010 @ 08:02 AM

    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'
    
  • Will Sargent

    Will Sargent April 27th, 2010 @ 08:07 AM

    It should be:

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

    Ryan Bigg April 27th, 2010 @ 08:35 AM

    • State changed from “new” to “needs-more-info”

    Please formulate a patch and attach it to this ticket.

  • James Sadler
  • Ryan Bigg

    Ryan Bigg April 27th, 2010 @ 10:45 AM

    • State changed from “needs-more-info” to “open”

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

    +1

  • Santiago Pastorino

    Santiago Pastorino April 29th, 2010 @ 03:44 PM

    This was fixed by 1d63129eff1e25dd22e182cdef40ec61bf5dde88

  • Ryan Bigg

    Ryan Bigg April 29th, 2010 @ 10:21 PM

    • State changed from “open” to “committed”

    Fixed by Xavier Noria in 1d63129eff1e25dd22e182cdef40ec61bf5dde88:

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

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Attachments

Referenced by

Pages