Error 500 if there is a single quote in the subject of a message

This is a known problem and we are working on a fix.

Typing ' (single quote symbol) in the Subject (i.e. title) of a message and submitting it triggers Error 500 (Unspecified Internal Error).


In the case shown, we have a message with subject Andrew's question. It contains the ' symbol. When trying to create a message, we will receive this screen:


The message would still be created and visible on the Forums page and sidebar, but if you try to open it, you'll receive the same error. This prevents you from doing anything with the message itself (reply, edit, vote, delete, etc.)

This is the log record for this error (log file .../apps/redmine/htdocs/log/production.log):

Completed 500 Internal Server Error in 356ms (ActiveRecord: 80.0ms)

ActionView::Template::Error (Mysql2::Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 't%' OR subject LIKE '%included%')' at line 1: SELECT messages.* FROM messages WHERE (subject LIKE '%JS%' OR subject LIKE '%isn't%' OR subject LIKE '%included%')):
    127:     <%# do |topic| %>
    128:     <% tokens = @topic.subject.strip.scan(%r{((\s|^)"[\s\w]+"(\s|$)|\S+)}).collect {|m| m.first.gsub(%r{(^\s*"\s*|\s*"\s*$)}, '')} || "" %>
    129:     <% if ActiveRecord::VERSION::MAJOR >= 4 %>
    130:       <% related_topics = Message.where({ |t| "subject LIKE '%#{t}%'" }.join(' OR ')).to_a.compact if tokens %>
    131:     <% else %>
    132:       <% related_topics =, @project, :limit => 5)[0].select{|m| m != @topic && m.parent_id == nil }.compact if tokens %>
    133:     <% end %>
  plugins/redmine_questions/app/views/messages/show.html.erb:130:in `block in _plugins_redmine_questions_app_views_messages_show_html_erb__1005890687_84854904'
  plugins/redmine_questions/app/views/messages/show.html.erb:105:in `_plugins_redmine_questions_app_views_messages_show_html_erb__1005890687_84854904'
  lib/redmine/sudo_mode.rb:63:in `sudo_mode'

That is why we recommend not to use single quotes in subjects (titles) of articles and forums until the problem is solved. In case you did receive this error screen, please contact our support team, send the log or give the link to this article in case the log record is the same.

Same message without the ' symbol ...


... is created normally.


Was this article helpful? Yes  No
43 from 70 found this helpful