wicked 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/.rvmrc CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env bash
2
2
 
3
- ruby_string="ruby-1.9.2-p290"
3
+ ruby_string="ruby-1.9.3"
4
4
  gemset_name="wicked"
5
5
 
6
6
  if rvm list strings | grep -q "${ruby_string}" ; then
@@ -1,3 +1,9 @@
1
+ ## 1.0.2 (8/15/2013)
2
+
3
+ * Contains Security updates plz upgrade
4
+ * Only allow params[:id] to be used as step if in valid list
5
+ * Better redirect handling thanks @gabrielg
6
+
1
7
  ## 1.0.1 (8/08/2013)
2
8
 
3
9
  * Fix security issue #94
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.1
1
+ 1.0.2
@@ -26,7 +26,7 @@ module Wicked::Controller::Concerns::RenderRedirect
26
26
  if the_step.nil? || the_step.to_s == Wicked::FINISH_STEP
27
27
  redirect_to_finish_wizard options
28
28
  else
29
- render ERB::Util.url_encode(the_step), options
29
+ render the_step, options
30
30
  end
31
31
  end
32
32
 
@@ -2,6 +2,18 @@ module Wicked
2
2
  module Wizard
3
3
  extend ActiveSupport::Concern
4
4
 
5
+ class InvalidStepError < RuntimeError
6
+ def initialize
7
+ super "The requested step did not match any steps defined for this controller."
8
+ end
9
+ end
10
+
11
+ class UndefinedStepsError < RuntimeError
12
+ def initialize
13
+ super "No step definitions have been supplied; if setting via `before_filter`, use `prepend_before_filter`"
14
+ end
15
+ end
16
+
5
17
  # Include the modules!!
6
18
  include Wicked::Controller::Concerns::Path
7
19
  include Wicked::Controller::Concerns::RenderRedirect
@@ -19,7 +31,7 @@ module Wicked
19
31
 
20
32
  # forward to first step with whatever params are provided
21
33
  def index
22
- redirect_to wizard_path(steps.first, clean_params)
34
+ redirect_to "#{wizard_path(steps.first)}?#{request.query_parameters.to_query}"
23
35
  end
24
36
 
25
37
  # returns the canonical value for a step name, needed for translation support
@@ -29,25 +41,26 @@ module Wicked
29
41
 
30
42
  private
31
43
 
32
- def clean_params
33
- params.except(:action, :controller)
34
- end
35
-
36
44
  def check_redirect_to_first_last!(step)
37
45
  redirect_to wizard_path(steps.first) if step.to_s == Wicked::FIRST_STEP
38
46
  redirect_to wizard_path(steps.last) if step.to_s == Wicked::LAST_STEP
39
47
  end
40
48
 
41
49
  def setup_step_from(the_step)
42
- the_step = the_step || steps.try(:first)
50
+ return if steps.nil?
51
+
52
+ the_step ||= steps.first
43
53
  check_redirect_to_first_last!(the_step)
44
- step = steps.detect {|stp| stp.to_s == the_step } if steps.present? && the_step.present?
45
- return step || the_step
54
+
55
+ valid_steps = steps + self.class::PROTECTED_STEPS
56
+ the_step = valid_steps.detect { |stp| stp.to_s == the_step }
57
+
58
+ raise InvalidStepError if the_step.nil?
59
+ the_step
46
60
  end
47
61
 
48
- def check_steps!(the_step)
49
- return false if step.nil?
50
- raise "Wicked Wizard steps expected but not yet set, if setting via `before_filter` use `prepend_before_filter`" if steps.nil?
62
+ def check_steps!
63
+ raise UndefinedStepsError if steps.nil?
51
64
  end
52
65
 
53
66
  def set_previous_next(step)
@@ -56,8 +69,10 @@ module Wicked
56
69
  end
57
70
 
58
71
  def setup_wizard
72
+ check_steps!
73
+ return if params[:id].nil?
74
+
59
75
  @step = setup_step_from(params[:id])
60
- check_steps!(@step)
61
76
  set_previous_next(@step)
62
77
  end
63
78
  public
@@ -79,9 +79,7 @@ module Wicked
79
79
  #
80
80
  def setup_wizard_translated
81
81
  self.steps = wizard_translations.keys # must come before setting previous/next steps
82
- @step = setup_step_from(params[:id])
83
- check_steps!(@step)
84
- set_previous_next(@step)
82
+ setup_wizard
85
83
  end
86
84
  public
87
85
  end
@@ -41,7 +41,7 @@ class IncludeNavigationTest < ActiveSupport::IntegrationCase
41
41
 
42
42
  test 'invalid step' do
43
43
  step = :notastep
44
- assert_raise(ActionView::MissingTemplate) do
44
+ assert_raise(Wicked::Wizard::InvalidStepError) do
45
45
  visit(bar_path(step))
46
46
  end
47
47
  end
@@ -4,7 +4,7 @@ class SecurityTest < ActiveSupport::IntegrationCase
4
4
 
5
5
  test 'does not show database.yml' do
6
6
  step = "%2E%2F%2E%2E%2F%2E%2E%2Fconfig%2Fdatabase%2Eyml"
7
- assert_raise ActionView::MissingTemplate do
7
+ assert_raise(Wicked::Wizard::InvalidStepError) do
8
8
  visit(bar_path(step))
9
9
  end
10
10
  refute has_content?('sqlite3')
@@ -15,7 +15,7 @@ class SecurityTest < ActiveSupport::IntegrationCase
15
15
  root = '%2E%2F%2E' * 100 # root of system
16
16
  step = root + '%2Fusr%2Fshare%2Fdict%2Fwords'
17
17
 
18
- assert_raise ActionView::MissingTemplate do
18
+ assert_raise(Wicked::Wizard::InvalidStepError) do
19
19
  visit(bar_path(step))
20
20
  end
21
21
  refute has_content?('aardvark')
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "wicked"
8
- s.version = "1.0.1"
8
+ s.version = "1.0.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["schneems"]
12
- s.date = "2013-10-08"
12
+ s.date = "2013-10-16"
13
13
  s.description = "Wicked is a Rails engine for producing easy wizard controllers"
14
14
  s.email = "richard.schneeman@gmail.com"
15
15
  s.extra_rdoc_files = [
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wicked
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-10-08 00:00:00.000000000 Z
12
+ date: 2013-10-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -238,7 +238,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
238
238
  version: '0'
239
239
  segments:
240
240
  - 0
241
- hash: -4073254236286297794
241
+ hash: 3158381855714249075
242
242
  required_rubygems_version: !ruby/object:Gem::Requirement
243
243
  none: false
244
244
  requirements: