[PATCH conductor] Input validation for new deployable from image

Tomas Sedovic tsedovic at redhat.com
Mon Dec 12 10:24:14 UTC 2011


On 12/09/2011 04:15 PM, tsedovic at redhat.com wrote:
> From: Tomas Sedovic<tomas at sedovic.cz>
>
> https://bugzilla.redhat.com/show_bug.cgi?id=761096
>
> When no catalog was selected on the Create Deployable from Image page, the
> controller called `Catalog.find(nil)` which returned
> `ActiveRecord::RecordNotFound` error which in turn caused the unexpected
> redirect.
> ---
>   src/app/controllers/deployables_controller.rb      |    2 +-
>   .../views/deployables/_new_from_image.html.haml    |    5 -----
>   2 files changed, 1 insertions(+), 6 deletions(-)
>
> diff --git a/src/app/controllers/deployables_controller.rb b/src/app/controllers/deployables_controller.rb
> index f5a894d..3f6116a 100644
> --- a/src/app/controllers/deployables_controller.rb
> +++ b/src/app/controllers/deployables_controller.rb
> @@ -87,7 +87,7 @@ class DeployablesController<  ApplicationController
>
>       require_privilege(Privilege::CREATE, Deployable)
>       @deployable = Deployable.new(params[:deployable])
> -    @selected_catalogs = Catalog.find(params[:catalog_id]).to_a
> +    @selected_catalogs = Catalog.find(params[:catalog_id] || []).to_a
>       @deployable.owner = current_user
>
>       if params.has_key? :url
> diff --git a/src/app/views/deployables/_new_from_image.html.haml b/src/app/views/deployables/_new_from_image.html.haml
> index b8030be..c2114ee 100644
> --- a/src/app/views/deployables/_new_from_image.html.haml
> +++ b/src/app/views/deployables/_new_from_image.html.haml
> @@ -17,7 +17,6 @@
>               .clear
>             %div
>               = form.label :catalog_id, t('catalog_entries.form.catalog')
> -            /= form.select :catalog_id, @catalogs.collect{|c| [c.name, c.id]}
>               %span.text_instead_input= @selected_catalogs.empty? ? t('deployables.form.none') : @selected_catalogs.count>  1 ? t('deployables.form.multiple') : @selected_catalogs.first.name
>               %span.catalog_link
>                 &nbsp
> @@ -34,7 +33,3 @@
>           %fieldset.align-center
>             = link_to "#{t'catalog_entries.form.cancel'}", catalogs_path, :class =>  'button danger'
>             = submit_tag "#{t'catalog_entries.form.save'}", :name =>  'save', :class =>  'button primary', :id =>  'save_button'
> -
> -:javascript
> -    $(document).ready(function(){
> -    });

Self-ack & pushed

-- 
No trees were killed to send this message, but a large number of 
electrons were terribly inconvenienced.



More information about the aeolus-devel mailing list