  def delete_attachment
    Log.add_info(request, params.inspect)

    return unless request.post?

    begin
      attachment = MailAttachment.find(params[:attachment_id])
      @email = Email.find(params[:id])

      if attachment.email_id == @email.id
        attachment.destroy

        update_attrs = ActionController::Parameters.new({updated_at: Time.now})
        if @email.status == Email::STATUS_TEMPORARY
          update_attrs[:status] = Email::STATUS_DRAFT
        end
        @email.update_attributes(update_attrs.permit(Email::PERMIT_BASE))
      end
    rescue => evar
      Log.add_error(request, evar)
    end

    render(:partial => 'ajax_mail_attachments', :layout => false)
  end
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.