active_scaffold 3.4.20 → 3.4.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 42baa20c0dc8c0bcc7f9d1f8f9458de2135d4def
4
- data.tar.gz: d5cf0f64b77a05dcf00dafbd57533df34033a18b
3
+ metadata.gz: 305b70bbadf4986fe5db1d87e33cabd4612d8ee7
4
+ data.tar.gz: 2a9a2f6b260bd3b73d1dfac99f1937c20034a615
5
5
  SHA512:
6
- metadata.gz: 9e45bf8388302307fe80cf19293c71efa2779289931fbe4fa852ab10b56c32c4b3b2f9da22d1a4c3426cf80879555e94b0722bd8395c5dbfe267bcc92400717c
7
- data.tar.gz: 869a983b83016caf7aaf93d213a2392e056ccfcc0c41b51149fd17292542fd5e42ee8083271f4b15e8ba25cd0d1a6844874e91823f7c06baf2c36aa53645b760
6
+ metadata.gz: f2d50d8c971e3765c6ddcbd341ac74b191833f8c45445ce22e5de6f798551c7b0be4484d36cbd08b18ee24d56cd783d28fa168025e8d068021607fd046a4b987
7
+ data.tar.gz: 5bfdbbf6b81a65da5629b59535805332e0e23dc6d178cc1461c7101048a30c53ea64d897f79f21d4ef8126efee67b907c47e8760baedfd9a85bf6bd8e5ae79d7
data/CHANGELOG CHANGED
@@ -1,3 +1,12 @@
1
+ = 3.4.21
2
+ - Fix excluding a bridge
3
+ - Allow to call helpers from dynamic_parameters proc
4
+ - Fix warn when form is changed on create/update loaded on page (without AJAX)
5
+ - Fix XSS vulnerability when using to_label with as_ (#425)
6
+ - Set cursor at end when focus first element
7
+ - Set focus on form.search after search with refresh_with_header
8
+
9
+ = 3.4.20
1
10
  - Update tinymce bridge for tinyMCE 4.x
2
11
  - Ignore :format in conditions_from_params
3
12
  - column with :radio form_ui works like :select form_ui in list and show
@@ -303,6 +303,11 @@ jQuery(document).ready(function($) {
303
303
  ActiveScaffold.live_search(e.target);
304
304
  ActiveScaffold.draggable_lists('.draggable-lists', e.target);
305
305
  });
306
+ jQuery(document).on('as:element_updated', '.active-scaffold', function(e) {
307
+ if (e.target != this) return;
308
+ var search = $(this).find('form.search');
309
+ if (search.length) ActiveScaffold.focus_first_element_of_form(search);
310
+ });
306
311
  jQuery(document).on('as:action_success', 'a.as_action', function(e, action_link) {
307
312
  ActiveScaffold.load_embedded(action_link.adapter);
308
313
  ActiveScaffold.enable_js_form_buttons(action_link.adapter);
@@ -607,7 +612,8 @@ var ActiveScaffold = {
607
612
  focus_first_element_of_form: function(form_element, form_selector) {
608
613
  if (typeof(form_element) == 'string') form_element = '#' + form_element;
609
614
  if (typeof(form_selector) == 'undefined') form_selector = jQuery(form_element).is('form') ? '' : 'form ';
610
- jQuery(form_selector + ":input:visible:first", jQuery(form_element)).focus();
615
+ var input = jQuery(form_selector + ":input:visible:first", jQuery(form_element)).focus();
616
+ if (input[0].value) input[0].selectionStart = input[0].selectionEnd = input[0].value.length;
611
617
  },
612
618
 
613
619
  create_record_row: function(active_scaffold_id, html, options) {
@@ -991,7 +997,7 @@ var ActiveScaffold = {
991
997
  $(document).on('change input', '.active-scaffold form:not(.search) input, .active-scaffold form:not(.search) textarea, .active-scaffold form:not(.search) select', function() {
992
998
  $(this).closest('form').addClass('need-confirm');
993
999
  });
994
- $(document).on('click', '.active-scaffold .as_cancel:not([data-remote])', function() {
1000
+ $(document).on('click', '.active-scaffold .as_cancel:not([data-remote]), .active-scaffold input[type=submit]', function() {
995
1001
  $(this).closest('form').removeClass('need-confirm');
996
1002
  });
997
1003
  window.onbeforeunload = function() {
@@ -1,4 +1,4 @@
1
- <h4><%= active_scaffold_config.show.label(@record.to_label.nil? ? nil : @record.to_label) %></h4>
1
+ <h4><%= active_scaffold_config.show.label(@record.to_label.nil? ? nil : h(@record.to_label)) %></h4>
2
2
 
3
3
  <%= render :partial => 'show_columns', :locals => {:columns => active_scaffold_config.show.columns} -%>
4
4
 
@@ -3,4 +3,4 @@
3
3
  :form_action => form_action ||= :update,
4
4
  :method => method ||= :put,
5
5
  :cancel_link => cancel_link,
6
- :headline => headline ||= @record.to_label.nil? ? active_scaffold_config.update.label : as_(:update_model, :model => @record.to_label)} %>
6
+ :headline => headline ||= @record.to_label.nil? ? active_scaffold_config.update.label : as_(:update_model, :model => h(@record.to_label))} %>
@@ -1,7 +1,7 @@
1
1
  <div class="active-scaffold">
2
2
  <div class="delete-view view">
3
3
  <%= form_tag params_for(:action => link.action, :id => params[:id]), { :method => link.method } %>
4
- <h4><%= link.confirm(record.try(:to_label)) -%></h4>
4
+ <h4><%= link.confirm(h(record.try(:to_label))) -%></h4>
5
5
 
6
6
  <p class="form-footer">
7
7
  <%= submit_tag as_(link.label), :class => 'submit' %>
@@ -1,7 +1,7 @@
1
1
  <div class="active-scaffold">
2
2
  <div class="delete-view view">
3
3
  <%= form_tag params_for(:action => :destroy, :id => params[:id]), { :method => :delete } %>
4
- <h4><%= as_(:are_you_sure_to_delete, :label => @record.try(:to_label)) -%></h4>
4
+ <h4><%= as_(:are_you_sure_to_delete, :label => h(@record.try(:to_label))) -%></h4>
5
5
 
6
6
  <p class="form-footer">
7
7
  <%= submit_tag as_(:delete), :class => 'submit' %>
@@ -40,7 +40,7 @@ module ActiveScaffold::Actions
40
40
  end
41
41
  else
42
42
  if successful?
43
- flash[:info] = as_(:created_model, :model => @record.to_label)
43
+ flash[:info] = as_(:created_model, :model => ERB::Util.h(@record.to_label))
44
44
  if (action = active_scaffold_config.create.action_after_create)
45
45
  redirect_to params_for(:action => action, :id => @record.to_param)
46
46
  elsif params[:dont_close]
@@ -14,7 +14,7 @@ module ActiveScaffold::Actions
14
14
  protected
15
15
 
16
16
  def destroy_respond_to_html
17
- flash[:info] = as_(:deleted_model, :model => @record.to_label) if self.successful?
17
+ flash[:info] = as_(:deleted_model, :model => ERB::Util.h(@record.to_label)) if self.successful?
18
18
  return_to_main
19
19
  end
20
20
 
@@ -46,7 +46,7 @@ module ActiveScaffold::Actions
46
46
  begin
47
47
  self.successful = record.destroy
48
48
  rescue StandardError => ex
49
- flash[:warning] = as_(:cant_destroy_record, :record => record.to_label)
49
+ flash[:warning] = as_(:cant_destroy_record, :record => ERB::Util.h(record.to_label))
50
50
  self.successful = false
51
51
  logger.debug ex.message
52
52
  logger.debug ex.backtrace.join("\n")
@@ -38,9 +38,9 @@ module ActiveScaffold::Actions
38
38
 
39
39
  def nested_label
40
40
  if nested.belongs_to?
41
- as_(:nested_of_model, :nested_model => active_scaffold_config.model.model_name.human, :parent_model => nested_parent_record.to_label)
41
+ as_(:nested_of_model, :nested_model => active_scaffold_config.model.model_name.human, :parent_model => ERB::Util.h(nested_parent_record.to_label))
42
42
  else
43
- as_(:nested_for_model, :nested_model => active_scaffold_config.list.label, :parent_model => nested_parent_record.to_label)
43
+ as_(:nested_for_model, :nested_model => active_scaffold_config.list.label, :parent_model => ERB::Util.h(nested_parent_record.to_label))
44
44
  end
45
45
  end
46
46
 
@@ -144,7 +144,7 @@ module ActiveScaffold::Actions::Nested
144
144
  end
145
145
 
146
146
  def destroy_existing
147
- return redirect_to(params.merge(:action => :delete)) if request.get?
147
+ return redirect_to(params.merge(:action => :delete, :only_path => true)) if request.get?
148
148
  do_destroy_existing
149
149
  respond_to_action(:destroy_existing)
150
150
  end
@@ -165,7 +165,7 @@ module ActiveScaffold::Actions::Nested
165
165
 
166
166
  def add_existing_respond_to_html
167
167
  if successful?
168
- flash[:info] = as_(:created_model, :model => @record.to_label)
168
+ flash[:info] = as_(:created_model, :model => ERB::Util.h(@record.to_label))
169
169
  return_to_main
170
170
  else
171
171
  render(:action => 'add_existing_form')
@@ -193,7 +193,7 @@ module ActiveScaffold::Actions::Nested
193
193
  end
194
194
 
195
195
  def destroy_existing_respond_to_html
196
- flash[:info] = as_(:deleted_model, :model => @record.to_label)
196
+ flash[:info] = as_(:deleted_model, :model => ERB::Util.h(@record.to_label))
197
197
  return_to_main
198
198
  end
199
199
 
@@ -43,7 +43,7 @@ module ActiveScaffold::Actions
43
43
  end
44
44
  else # just a regular post
45
45
  if successful?
46
- message = as_(:updated_model, :model => @record.to_label)
46
+ message = as_(:updated_model, :model => ERB::Util.h(@record.to_label))
47
47
  if params[:dont_close]
48
48
  flash.now[:info] = message
49
49
  render(:action => 'update')
@@ -68,7 +68,7 @@ module ActiveScaffold::Actions
68
68
  @record = get_row rescue nil # if record doesn't fullfil current conditions remove it from list
69
69
  end
70
70
  end
71
- flash.now[:info] = as_(:updated_model, :model => (@updated_record || @record).to_label) if active_scaffold_config.update.persistent
71
+ flash.now[:info] = as_(:updated_model, :model => ERB::Util.h((@updated_record || @record).to_label)) if active_scaffold_config.update.persistent
72
72
  end
73
73
  render :action => 'on_update'
74
74
  end
@@ -45,7 +45,7 @@ module ActiveScaffold
45
45
  return false if bridges_prepared
46
46
  bridges.keys.each do |bridge_name|
47
47
  bridge = self[bridge_name]
48
- bridge.prepare if bridge.install?
48
+ bridge.prepare if bridge && bridge.install?
49
49
  end
50
50
  self.bridges_prepared = true
51
51
  end
@@ -246,7 +246,7 @@ module ActiveScaffold
246
246
  end
247
247
 
248
248
  def replace_id_params_in_action_link_url(link, record, url)
249
- url = record ? url.sub('--ID--', record.to_param) : url.clone
249
+ url = record ? url.sub('--ID--', record.to_param.to_s) : url.clone
250
250
  if link.column.try(:singular_association?)
251
251
  child_id = record.send(link.column.association.name).try(:to_param)
252
252
  if child_id.present?
@@ -333,9 +333,9 @@ module ActiveScaffold
333
333
  url_options.merge! link.parameters if link.parameters
334
334
  if link.dynamic_parameters.is_a?(Proc)
335
335
  if record.nil?
336
- url_options.merge! link.dynamic_parameters.call
336
+ url_options.merge! instance_exec &link.dynamic_parameters
337
337
  else
338
- url_options.merge! link.dynamic_parameters.call(record)
338
+ url_options.merge! instance_exec record, &link.dynamic_parameters
339
339
  end
340
340
  end
341
341
  if link.nested_link?
@@ -384,7 +384,7 @@ module ActiveScaffold
384
384
  html_options[:method] = link.method if link.method != :get
385
385
 
386
386
  html_options[:data] ||= {}
387
- html_options[:data][:confirm] = link.confirm(record.try(:to_label)) if link.confirm?
387
+ html_options[:data][:confirm] = link.confirm(h(record.try(:to_label))) if link.confirm?
388
388
  if link.inline?
389
389
  html_options[:class] << ' as_action'
390
390
  html_options[:data][:position] = link.position if link.position
@@ -2,7 +2,7 @@ module ActiveScaffold
2
2
  module Version
3
3
  MAJOR = 3
4
4
  MINOR = 4
5
- PATCH = 20
5
+ PATCH = 21
6
6
 
7
7
  STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_scaffold
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.20
4
+ version: 3.4.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - Many, see README
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-16 00:00:00.000000000 Z
11
+ date: 2015-05-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: brakeman