be090129 / substruct

Automatically exported from code.google.com/p/substruct
0 stars 0 forks source link

PATCH The system crashes when passing an invalid tag in the front face site. #96

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Enter an URL that have an invalid tag at the address bar. i.e.
http://localhost:3000/store/show_by_tags/invalid

What is the expected output? What do you see instead?
It should handle it gracefully. It crashes with an
ActiveRecord::StatementInvalid exception.

What version of the product are you using? On what operating system?
trunk. Ubuntu 7.10

Please provide any additional information below.
The show_by_tags method don't validate the data after trying to get it from
the database. Even when empty it tries to use it.

Now, if any tag or subtag is not found, it redirects to index with a flash
message indicating the problem tag.

Original issue reported on code.google.com by edmundo...@gmail.com on 10 Jun 2008 at 1:46

Attachments:

GoogleCodeExporter commented 8 years ago
This is not a complete fix. Navigate to:

http://localhost:3000/store/show_by_tags/

--or--

http://localhost:3000/store/show_by_tags

Original comment by patrickb...@gmail.com on 10 Jun 2008 at 8:02

GoogleCodeExporter commented 8 years ago
if @tag_names.empty?
      redirect_to :controller => 'homepage', :action => 'index' and return false
    else
          for name in @tag_names
            temp_tag = Tag.find_by_name(name)
            if temp_tag then
                tag_ids_array << temp_tag.id
            else
          flash[:notice] = "Sorry, we couldn't find the tag #{name} you were looking
for."
          redirect_to :controller => 'homepage', :action => 'index' and return false
        end
          end
    end

Original comment by patrickb...@gmail.com on 10 Jun 2008 at 9:05

GoogleCodeExporter commented 8 years ago
thanks. fixed.

Original comment by edmundo...@gmail.com on 10 Jun 2008 at 9:59

Attachments:

GoogleCodeExporter commented 8 years ago
Thanks for the heads up. Fixed in r91, but instead of using a flash I'm 
rendering a 404 page, which is the 
expected behavior for things of this nature.

No reason to reinvent the wheel ;)

Original comment by subim...@gmail.com on 15 Jun 2008 at 5:18