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.

This project is archived and is in readonly mode.

Framework crashes on launch on Solaris with invalid encoding ("ascii//ignore//translit", "utf-8")

#1396

As described http://woss.name/2008/10/16/edge...

The version of iconv provided with Solaris doesn't support the "ascii//translit//IGNORE" encoding. The fix descibed through the link is to recompile or relink to a compatible iconv library. Unfortunately this option isn't always available.

inflector.rb provides a fallback transliterate method, but this doesn't kick in on Solaris due to the raised error.

Reported by Jeremy · November 18th, 2008 @ 02:29 AM

State: stale
Milestone: none
Assigned to: Michael Koziarski Michael Koziarski
Importance: none

Activity

  1. James Ravn
    James Ravn

    As a quick fix, you can do something like this in activesupport/lib/active_support/inflector.rb:

     # Replaces accented characters with their ascii equivalents.
     def transliterate(string)
    
    
    • Iconv.iconv('ascii//ignore//translit', 'utf-8', string).to_s
    • begin
    •  Iconv.iconv('ascii//ignore//translit', 'utf-8', string).to_s
      
      
    • rescue Iconv::InvalidEncoding
    • end end

    November 26th, 2008 @ 07:17 PM

  2. James Ravn
    James Ravn

    Let's try that again (why make it hard to paste diffs?):

    
         # Replaces accented characters with their ascii equivalents.
         def transliterate(string)
    -      Iconv.iconv('ascii//ignore//translit', 'utf-8', string).to_s
    +      begin
    +        Iconv.iconv('ascii//ignore//translit', 'utf-8', string).to_s
    +      rescue Iconv::InvalidEncoding
    +      end
         end
    

    November 26th, 2008 @ 07:20 PM

  3. iGEL
    iGEL
    • Tag changed from 2.2.rc2, inflector to 2.2, 2.2-stable, 2.2.2, 2.2.rc2, inflector

    I confirm the bug and the fix by James Ravn. Tested with Rails 2.2.2

    December 1st, 2008 @ 04:22 PM

  4. Henrik Nyh
    Henrik Nyh
    • Tag changed from 2.2, 2.2-stable, 2.2.2, 2.2.rc2, inflector to 2.2, 2.2-stable, 2.2.2, 2.2.rc2, inflector, patch

    +1 on fix, makes sense.

    December 1st, 2008 @ 04:41 PM

  5. Henrik Nyh
    Henrik Nyh

    It'd look nicer if the rescue returned the original string rather than nil, I think. No practical difference, though.

    December 1st, 2008 @ 04:43 PM

  6. pedz
    pedz

    +1

    This is needed on AIX as well.

    December 12th, 2008 @ 03:39 PM

  7. Jeremy Kemper
    Jeremy Kemper
    • Assigned user set to Jeremy Kemper
    • State changed from new to open
    • Milestone cleared.

    Good catch. Please attach a patch and test.

    December 12th, 2008 @ 08:22 PM

  8. jcapote (at gmail)
    jcapote (at gmail)

    I confirm the bug and the fix by James Ravn. Tested with Rails 2.2.2

    December 15th, 2008 @ 06:39 AM

  9. Jeremy Kemper
    Jeremy Kemper
    • State changed from open to verified

    Still needs a test case.

    December 15th, 2008 @ 05:50 PM

  10. James Ravn
    James Ravn

    Patch attached.

    Note: It will use the built in transliterate after the test is run, which I don't think is a problem. I'd prefer if the test reloaded inflector.rb in a separate namespace, but that causes issues with constant lookups.

    January 13th, 2009 @ 06:07 PM

  11. Pratik
    Pratik
    • Milestone cleared.
    • Assigned user changed from Jeremy Kemper to Michael Koziarski

    January 18th, 2009 @ 03:47 AM

  12. Michael Koziarski
    Michael Koziarski

    I'd prefer it if we moved the exception rescuing into the 'compile time' stuff rather than the code which is called at runtime, we could be hiding other errors and returning nil in cases people wouldn't expect it.

    Other than that this looks good, well tested too.

    January 18th, 2009 @ 08:28 AM

  13. James Ravn
    James Ravn

    Here's an updated patch that does the rescue during class definition or "compile time". I also expanded the test class so the pure ruby transliterate method is checked.

    January 19th, 2009 @ 12:11 AM

  14. Michael Koziarski
    Michael Koziarski
    • State changed from verified to incomplete

    This patch causes several errors and warnings on macosx:

    /Library/Ruby/Gems/1.8/gems/rake-0.8.3/lib/rake/gempackagetask.rb:13:Warning: Gem::manage_gems is deprecated and will be removed on or after March 2009. /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -w -Ilib:test "/Library/Ruby/Gems/1.8/gems/rake-0.8.3/lib/rake/rake_test_loader.rb" "test/buffered_logger_test.rb" "test/caching_test.rb" "test/callbacks_test.rb" "test/clean_backtrace_test.rb" "test/clean_logger_test.rb" "test/core_ext/array_ext_test.rb" "test/core_ext/base64_ext_test.rb" "test/core_ext/blank_test.rb" "test/core_ext/cgi_ext_test.rb" "test/core_ext/class/attribute_accessor_test.rb" "test/core_ext/class/class_inheritable_attributes_test.rb" "test/core_ext/class/delegating_attributes_test.rb" "test/core_ext/class_test.rb" "test/core_ext/date_ext_test.rb" "test/core_ext/date_time_ext_test.rb" "test/core_ext/duplicable_test.rb" "test/core_ext/duration_test.rb" "test/core_ext/enumerable_test.rb" "test/core_ext/exception_test.rb" "test/core_ext/file_test.rb" "test/core_ext/float_ext_test.rb" "test/core_ext/hash_ext_test.rb" "test/core_ext/integer_ext_test.rb" "test/core_ext/kernel_test.rb" "test/core_ext/load_error_test.rb" "test/core_ext/module/attr_accessor_with_default_test.rb" "test/core_ext/module/attr_internal_test.rb" "test/core_ext/module/attribute_accessor_test.rb" "test/core_ext/module/attribute_aliasing_test.rb" "test/core_ext/module/model_naming_test.rb" "test/core_ext/module/synchronization_test.rb" "test/core_ext/module_test.rb" "test/core_ext/name_error_test.rb" "test/core_ext/numeric_ext_test.rb" "test/core_ext/object_and_class_ext_test.rb" "test/core_ext/object_ext_test.rb" "test/core_ext/pathname_test.rb" "test/core_ext/proc_test.rb" "test/core_ext/range_ext_test.rb" "test/core_ext/string_ext_test.rb" "test/core_ext/symbol_test.rb" "test/core_ext/time_ext_test.rb" "test/core_ext/time_with_zone_test.rb" "test/dependencies_test.rb" "test/deprecation_test.rb" "test/gzip_test.rb" "test/i18n_test.rb" "test/inflector_test.rb" "test/json/decoding_test.rb" "test/json/encoding_test.rb" "test/memoizable_test.rb" "test/message_encryptor_test.rb" "test/message_verifier_test.rb" "test/multibyte_chars_test.rb" "test/multibyte_unicode_database_test.rb" "test/option_merger_test.rb" "test/ordered_hash_test.rb" "test/ordered_options_test.rb" "test/rescuable_test.rb" "test/secure_random_test.rb" "test/string_inquirer_test.rb" "test/test_test.rb" "test/time_zone_test.rb" "test/whiny_nil_test.rb" ./test/../lib/active_support/core_ext/try.rb:23: warning: discarding old try Skipping memcached backed store tests. Start memcached and try again. Loaded suite /Library/Ruby/Gems/1.8/gems/rake-0.8.3/lib/rake/rake_test_loader Started ......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................./test/../lib/active_support/inflector.rb:37: warning: method redefined; discarding old initialize ./test/../lib/active_support/inflector.rb:43: warning: method redefined; discarding old plural ./test/../lib/active_support/inflector.rb:51: warning: method redefined; discarding old singular ./test/../lib/active_support/inflector.rb:63: warning: method redefined; discarding old irregular ./test/../lib/active_support/inflector.rb:83: warning: method redefined; discarding old uncountable ./test/../lib/active_support/inflector.rb:94: warning: method redefined; discarding old human ./test/../lib/active_support/inflector.rb:105: warning: method redefined; discarding old clear ./test/../lib/active_support/inflector.rb:122: warning: method redefined; discarding old inflections ./test/../lib/active_support/inflector.rb:138: warning: method redefined; discarding old pluralize ./test/../lib/active_support/inflector.rb:157: warning: method redefined; discarding old singularize ./test/../lib/active_support/inflector.rb:178: warning: method redefined; discarding old camelize ./test/../lib/active_support/inflector.rb:195: warning: method redefined; discarding old titleize ./test/../lib/active_support/inflector.rb:206: warning: method redefined; discarding old underscore ./test/../lib/active_support/inflector.rb:218: warning: method redefined; discarding old dasherize ./test/../lib/active_support/inflector.rb:228: warning: method redefined; discarding old humanize ./test/../lib/active_support/inflector.rb:240: warning: method redefined; discarding old demodulize ./test/../lib/active_support/inflector.rb:259: warning: method redefined; discarding old parameterize ./test/../lib/active_support/inflector.rb:274: warning: method redefined; discarding old transliterate ./test/../lib/active_support/inflector.rb:309: warning: method redefined; discarding old tableize ./test/../lib/active_support/inflector.rb:323: warning: method redefined; discarding old classify ./test/../lib/active_support/inflector.rb:336: warning: method redefined; discarding old foreign_key ./test/../lib/active_support/inflector.rb:360: warning: method redefined; discarding old constantize ./test/../lib/active_support/inflector.rb:391: warning: method redefined; discarding old ordinalize ....................................................FF................................................................................................................................................................................................F.....FF.....F...................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... Finished in 8.412096 seconds.

    1) Failure: test_partial_path(ModelNamingTest)

    [./test/core_ext/module/model_naming_test.rb:17:in `test_partial_path'
     /Library/Ruby/Gems/1.8/gems/mocha-0.9.3/lib/mocha/test_case_adapter.rb:69:in `__send__'
     /Library/Ruby/Gems/1.8/gems/mocha-0.9.3/lib/mocha/test_case_adapter.rb:69:in `run']:
    
    

    <"post/track_backs/track_back"> expected but was <"post/track_back/track_back">.

    2) Failure: test_plural(ModelNamingTest)

    [./test/core_ext/module/model_naming_test.rb:13:in `test_plural'
     /Library/Ruby/Gems/1.8/gems/mocha-0.9.3/lib/mocha/test_case_adapter.rb:69:in `__send__'
     /Library/Ruby/Gems/1.8/gems/mocha-0.9.3/lib/mocha/test_case_adapter.rb:69:in `run']:
    
    

    <"post_track_backs"> expected but was <"post_track_back">.

    3) Failure: test_classify(StringInflectionsTest)

    [./test/core_ext/string_ext_test.rb:76:in `test_classify'
     ./test/core_ext/string_ext_test.rb:75:in `each'
     ./test/core_ext/string_ext_test.rb:75:in `test_classify'
     /Library/Ruby/Gems/1.8/gems/mocha-0.9.3/lib/mocha/test_case_adapter.rb:69:in `__send__'
     /Library/Ruby/Gems/1.8/gems/mocha-0.9.3/lib/mocha/test_case_adapter.rb:69:in `run']:
    
    

    <"NodeChild"> expected but was <"NodeChildren">.

    4) Failure: test_pluralize(StringInflectionsTest)

    [./test/core_ext/string_ext_test.rb:11:in `test_pluralize'
     ./test/core_ext/string_ext_test.rb:10:in `each'
     ./test/core_ext/string_ext_test.rb:10:in `test_pluralize'
     /Library/Ruby/Gems/1.8/gems/mocha-0.9.3/lib/mocha/test_case_adapter.rb:69:in `__send__'
     /Library/Ruby/Gems/1.8/gems/mocha-0.9.3/lib/mocha/test_case_adapter.rb:69:in `run']:
    
    

    <"tomatoes"> expected but was <"tomato">.

    5) Failure: test_singularize(StringInflectionsTest)

    [./test/core_ext/string_ext_test.rb:19:in `test_singularize'
     ./test/core_ext/string_ext_test.rb:18:in `each'
     ./test/core_ext/string_ext_test.rb:18:in `test_singularize'
     /Library/Ruby/Gems/1.8/gems/mocha-0.9.3/lib/mocha/test_case_adapter.rb:69:in `__send__'
     /Library/Ruby/Gems/1.8/gems/mocha-0.9.3/lib/mocha/test_case_adapter.rb:69:in `run']:
    
    

    <"tomato"> expected but was <"tomatoes">.

    6) Failure: test_tableize(StringInflectionsTest)

    [./test/core_ext/string_ext_test.rb:70:in `test_tableize'
     ./test/core_ext/string_ext_test.rb:69:in `each'
     ./test/core_ext/string_ext_test.rb:69:in `test_tableize'
     /Library/Ruby/Gems/1.8/gems/mocha-0.9.3/lib/mocha/test_case_adapter.rb:69:in `__send__'
     /Library/Ruby/Gems/1.8/gems/mocha-0.9.3/lib/mocha/test_case_adapter.rb:69:in `run']:
    
    

    <"node_children"> expected but was <"node_child">.

    1632 tests, 7074 assertions, 6 failures, 0 errors rake aborted! Command failed with status (1): [/System/Library/Frameworks/Ruby.framework/...]

    January 26th, 2009 @ 03:22 AM

  15. Amanda Waite
    Amanda Waite

    I notice that this is fixed, at least on OpenSolaris in 2.3 RC2. The change I see between 2.2.2 and 2.3.1 is attached. Is there likely to be another 2.2.x update? I assume not but wanted to check.

    March 10th, 2009 @ 02:31 PM

  16. Michael Koziarski
    Michael Koziarski

    Yes, we plan to do a 2.2.3 to tidy up all the fixes in 2-2-stable. Hopefully we'll have an ETA soon.

    March 10th, 2009 @ 10:48 PM

  17. Amanda Waite
    Amanda Waite

    That's great, I hesitate to ask, but will the fix for this particular issue be in Rails/activesupport 2.2.3?

    March 11th, 2009 @ 11:06 AM

  18. Norman Clarke
    Norman Clarke
    • Tag changed from 2.2, 2.2-stable, 2.2.2, 2.2.rc2, inflector, patch to 2.2, 2.2-stable, 2.2.2, 2.2.rc2, inflector, invalid, patch

    AS 3.0's Inflector no longer uses Iconv, so this shouldn't be relevant any more.

    May 29th, 2010 @ 10:10 PM

  19. Santiago Pastorino
    Santiago Pastorino
    • State changed from incomplete to open
    • Tag changed from 2.2, 2.2-stable, 2.2.2, 2.2.rc2, inflector, invalid, patch to 22, 22-stable, 222, 22rc2, inflector, invalid, patch
    • Importance changed from to

    This issue has been automatically marked as stale because it has not been commented on for at least three months.

    The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.

    Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.

    February 2nd, 2011 @ 04:52 PM

  20. Santiago Pastorino
    Santiago Pastorino
    • State changed from open to stale

    February 2nd, 2011 @ 04:52 PM