ChiliProject is not maintained anymore. Please be advised that there will be no more updates.

We do not recommend that you setup new ChiliProject instances and we urge all existing users to migrate their data to a maintained system, e.g. Redmine. We will provide a migration script later. In the meantime, you can use the instructions by Christian Daehn.

Adding users with a dash "-" in email address is broken

Added by Chris Serio at 2011-11-24 02:57 am

I have ChiliProject 2.4.0 installed on an Ubuntu server with Apache2. When i create a user with an email address with a dash such as I get a 500 internal error with this stack:

Notice the "y-d". Why is it trying to do transliteration on my email address? Anyone know how to solve this? My entire company's email addresses have dashes in them.

ArgumentError (invalid range "y-d" in string transliteration):
app/models/mailer.rb:399:in `delete'
app/models/mailer.rb:399:in `create_mail'
app/controllers/users_controller.rb:106:in `create'
<internal:prelude>:10:in `synchronize'
passenger (3.0.9) lib/phusion_passenger/rack/request_handler.rb:96:in `process_request'
passenger (3.0.9) lib/phusion_passenger/abstract_request_handler.rb:513:in `accept_and_process_next_request'
passenger (3.0.9) lib/phusion_passenger/abstract_request_handler.rb:274:in `main_loop'
passenger (3.0.9) lib/phusion_passenger/classic_rails/application_spawner.rb:321:in `start_request_handler'
passenger (3.0.9) lib/phusion_passenger/classic_rails/application_spawner.rb:275:in `block in handle_spawn_application'
passenger (3.0.9) lib/phusion_passenger/utils.rb:479:in `safe_fork'
passenger (3.0.9) lib/phusion_passenger/classic_rails/application_spawner.rb:270:in `handle_spawn_application'
passenger (3.0.9) lib/phusion_passenger/abstract_server.rb:357:in `server_main_loop'
passenger (3.0.9) lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously'
passenger (3.0.9) lib/phusion_passenger/abstract_server.rb:180:in `start'
passenger (3.0.9) lib/phusion_passenger/classic_rails/application_spawner.rb:149:in `start'
passenger (3.0.9) lib/phusion_passenger/spawn_manager.rb:219:in `block (2 levels) in spawn_rails_application'
passenger (3.0.9) lib/phusion_passenger/abstract_server_collection.rb:132:in `lookup_or_add'
passenger (3.0.9) lib/phusion_passenger/spawn_manager.rb:214:in `block in spawn_rails_application'
passenger (3.0.9) lib/phusion_passenger/abstract_server_collection.rb:82:in `block in synchronize'
<internal:prelude>:10:in `synchronize'
passenger (3.0.9) lib/phusion_passenger/abstract_server_collection.rb:79:in `synchronize'
passenger (3.0.9) lib/phusion_passenger/spawn_manager.rb:213:in `spawn_rails_application'
passenger (3.0.9) lib/phusion_passenger/spawn_manager.rb:132:in `spawn_application'
passenger (3.0.9) lib/phusion_passenger/spawn_manager.rb:275:in `handle_spawn_application'
passenger (3.0.9) lib/phusion_passenger/abstract_server.rb:357:in `server_main_loop'
passenger (3.0.9) lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously'
passenger (3.0.9) helper-scripts/passenger-spawn-server:99:in `<main>'


Replies (6)

RE: Adding users with a dash "-" in email address is broken - Added by Felix Schäfer at 2011-11-27 06:31 pm

I wasn't able to reproduce this. Is this a clean install or an upgrade of a previous version? Do you have any plugins installed?

RE: Adding users with a dash "-" in email address is broken - Added by Felix Schäfer at 2011-11-27 06:37 pm

OK, I tried a little harder because it seems this only gets triggered if the user doing the action has checked "I don't want to to be notified about actions I do" in his preferences, and this probably also happens if the user doing the action has a dash in his mail address, but even doing all this I couldn't reproduce it.

Could you please open a new issue and add what ruby (1.8.6, 1.8.7, 1.9.2?) you are using and more generally what you can add from the "I've found a bug" section on Contribute? Thanks!

RE: Adding users with a dash "-" in email address is broken - Added by Chris Serio at 2011-11-27 06:37 pm

This is a clean install. I fixed it locally but my ruby knowledge is terrible so someone else should definitely look into this..

Go to app/models/mailer.rb around line 399. You'll see the code below.

Look at the variable "recipients". Sometimes recipients is an array and then calling "delete" on the array removes any elements that contain the email address that is marked as "don't self notify". This works fine...HOWEVER, sometimes recipients is NOT an array and just contains a single string. In this case, the "delete" method being called is NOT on an array object but on a STRING object which interprets a dash as a range of values and that's why it crashes.

# Overrides the create_mail method
  def create_mail
    # Removes the current user from the recipients and cc
    # if he doesn't want to receive notifications about what he does
    @author ||= User.current
    if @author.pref[:no_self_notified]
      recipients.delete(@author.mail) if recipients
      cc.delete(@author.mail) if cc
    end

    notified_users = [recipients, cc].flatten.compact.uniq
    # Rails would log recipients only, not cc and bcc
    mylogger.info "Sending email notification to: #{notified_users.join(', ')}" if mylogger

    # Blind carbon copy recipients
    if Setting.bcc_recipients?
      bcc(notified_users)
      recipients []
      cc []
    end
    super
  end

RE: Adding users with a dash "-" in email address is broken - Added by Felix Schäfer at 2011-11-27 06:44 pm

Chris Serio wrote:

Oh and I'm using Ruby 1.9.2.

That's probably the gist of the problem, I'll have a look with that. You mind opening an issue nonetheless so that we can track the issue? (I'll do it if you don't want to).

(1-6/6)