Commit Graph

339 Commits

Author SHA1 Message Date
Rafael Mendonça França
8b20c72dd8 Preparing for 4.1.0.beta2 release 2014-02-18 15:45:20 -03:00
Rafael Mendonça França
08d0a11a3f Escape format, negative_format and units options of number helpers
Previously the values of these options were trusted leading to
potential XSS vulnerabilities.

Fixes: CVE-2014-0081
2014-02-18 15:38:50 -03:00
Prem Sichanugrist
3047376870 Add #no_content_type attribute to AD::Response
Setting this attribute to `true` will remove the content type header
from the request. This is use in `render :body` feature.
2014-02-18 12:11:41 -05:00
Prem Sichanugrist
9fe506e394 Add missing CHANGELOG entry to Action View 2014-02-18 12:11:41 -05:00
Prem Sichanugrist
243e6e4b2a Fix a fragile test on action_view/render
This test were assuming that the list of render options will always be
the same. Fixing that so this doesn't break when we add/remove render
option in the future.
2014-02-18 12:08:36 -05:00
Prem Sichanugrist
920f3ba266 Introduce render :html for render HTML string
This is an option for to HTML content with a content type of
`text/html`. This rendering option calls `ERB::Util.html_escape`
internally to escape unsafe HTML string, so you will have to mark your
string as html safe if you have any HTML tag in it.

Please see #12374 for more detail.
2014-02-18 12:08:36 -05:00
Prem Sichanugrist
8cd9f6d205 Introduce render :plain for render plain text
This is as an option to render content with a content type of
`text/plain`. This is the preferred option if you are planning to render
a plain text content.

Please see #12374 for more detail.
2014-02-18 12:08:36 -05:00
Prem Sichanugrist
103e18c87d Introduce render :body for render raw content
This is an option for sending a raw content back to browser. Note that
this rendering option will unset the default content type and does not
include "Content-Type" header back in the response.

You should only use this option if you are expecting the "Content-Type"
header to not be set. More information on "Content-Type" header can be
found on RFC 2616, section 7.2.1.

Please see #12374 for more detail.
2014-02-18 12:08:36 -05:00
Xavier Noria
5f295aebdb implements new option :month_format_string for date select helpers [Closes #13618] 2014-02-15 10:27:15 +01:00
Lukasz Strzalkowski
f9b6b865e6 Variant negotiation
Allow setting `request.variant` as an array - an order in which they will be
rendered.

For example:

  request.variant = [:tablet, :phone]

  respond_to do |format|
    format.html.none
    format.html.phone # this gets rendered
  end
2014-02-13 16:22:56 +01:00
Iain Beeston
5b793a8add Added tests to render helper that expect render partial: @foo to
automatically call @foo.to_partial_path

Calling `render @foo` allows local variables but not options to be
passed to the partial renderer. The correct way to render an object AND
pass options to the partial renderer is to pass the object in the
`:partial` parameter. However, there were previously no tests for this
behaviour (in `render_helper_test.rb` at least).
2014-02-12 17:40:52 +00:00
Yves Senn
28abd967fc Merge pull request #11770 from timruffles/doc_ajax_xhr
be more specific about csrf token and ajax - not whitelisted outside of jquery-rails [ci skip]
2014-02-03 08:38:44 -08:00
Attila Domokos
4b4db54e6b Adding an documentation example and a test to button_to with path
I did not see in the docs that `button_to` supports not only URLs but paths as well. I documented this functionality with a unit tests and added an example to the docs as well.
2014-02-02 10:27:18 -06:00
Aaron Patterson
3fbff7811b just require the template resolver
LookupContext is eagerly loaded, and FallbackFileSystemResolver is
referenced at the class level.  Just require the resolver from the
eagerly loaded class rather than jumping through autoload hoops
2014-01-31 12:05:50 -08:00
Aaron Patterson
e8fcd599ba only ask for the location filters once 2014-01-31 12:00:54 -08:00
Carlos Antonio da Silva
8c7e8b4f18 Minor changelog improvements [ci skip] 2014-01-31 08:02:56 -02:00
Yves Senn
02f9f33142 tidy CHANGELOGs [ci skip] 2014-01-30 11:12:46 +01:00
Kassio Borges
433628a45c Rails config for raise on missing translations
Add a config to setup whether raise exception for missing translation or
not.
2014-01-27 08:03:46 -02:00
Rafael Mendonça França
662f8de06f Merge pull request #13414 from britto/jb-fix-dependency-matching
Improve ERB dependency detection
2014-01-16 13:38:12 -08:00
Waynn Lue
fd68adc8a9 "serie" => "series" 2014-01-13 14:23:58 -08:00
Gaurish Sharma
35e56f6fa5 standardize on jruby_skip & rbx_skip
This Adds helpers(jruby_skip & rbx_skip). In Future, Plan is to use
these helpers instead of calls directly to
RUBY_ENGINE/RbConfig/JRUBY_VERSION
2014-01-13 19:51:47 +05:30
João Britto
e987dcd78f Update changelog 2014-01-09 20:47:14 -02:00
João Britto
ccbba3ff50 Avoid scanning multiple render calls as a single match.
Each chunk of text coming after `render` is now handled individually as a possible list of arguments.
2014-01-09 20:37:00 -02:00
João Britto
c2afa05561 Improve ERB dependency detection.
The current implementation can't handle some special cases of oddly-formatted Ruby. Now we are able to detect them:

* Multi-line arguments on the `render` call
* Strings containing quotes, e.g. `"something's wrong"`
* Multiple kinds of identifiers - instance variables, class variables and globals
* Method chains as arguments for the `render` call

Also, this fix reduces the rate of "false positives" which showed up when we had calls/access to identifiers containing `render`, like `surrender` and `rendering`.
2014-01-09 20:36:59 -02:00
Adrien
98c3586415 Fix typo in image_tag documentation
image_tag only supports :alt and :size as additional keys, not three.
2014-01-07 12:38:24 +01:00
Washington Luiz
a5d92e6a1d Require actionview/version
just like all the other modules do require their version file
2014-01-06 02:52:46 -03:00
Gaelian Ditchburn
7a085dac2a Switched to use display:none in extra_tags_for_form method.
The use of `display:inline` with the content_tag call in the
extra_tags_for_form method potentially causes display issues with some
browsers, namely Internet Explorer. IE's behaviour of not collapsing
the line height on divs with ostensibly no content means that the
automatically added div containing the hidden authenticity_token, utf8
and _method form input tags may interfere with other visible form
elements in certain circumstances. The use of `display:none` rather
than `display:inline` fixes this problem.

Fixes #6403
2014-01-05 17:16:22 +00:00
Kuldeep Aggarwal
e9bfeb0c79 provide correct example of datetime_select helper [ci skip] 2014-01-04 23:59:20 +05:30
Konstantin Wlasow
9882ec4a50 Fixed documentation. [ci skip] 2014-01-04 16:18:16 +06:00
T.J. Schuck
72bb3fc297 Change all "can not"s to the correct "cannot". 2014-01-03 17:02:31 -05:00
Rafael Mendonça França
f89266ace8 No need to use fixed size font [ci skip] 2014-01-03 16:42:30 -02:00
Prathamesh Sonpatki
2126c24af6 Fix documentation for end_year option of date_helper [ci skip]
- While editing an existing record, end_year is equal to current selected year plus 5 by default.
- While editing an existing record, start_year is equal to current selected year value minus 5 by default.
- Fixes #13552

Acked-by: Prathamesh Sonpatki <csonpatki@gmail.com>

Acked-by: Prathamesh Sonpatki <csonpatki@gmail.com>
2014-01-03 21:46:21 +05:30
Kuldeep Aggarwal
ed62584391 provide correct information [ci skip] 2014-01-02 19:28:28 +05:30
Vipul A M
98cb3e69af update copyright notices to 2014. [ci skip] 2014-01-01 23:59:49 +05:30
Akira Matsuda
f57e5f224b Unused class in AV test 2013-12-25 10:33:42 +09:00
Akira Matsuda
222f00b422 Unused classes in AV tests 2013-12-24 11:04:49 +09:00
Robin Dupret
2bc88d4f74 Add a changelog entry for #13363 [ci skip] 2013-12-21 14:03:14 +01:00
Vijay Dev
a3b1105ada Merge branch 'master' of github.com:lifo/docrails 2013-12-20 00:10:30 +05:30
Carlos Antonio da Silva
c5b76b5362 Prefer assert_raise instead of flunk + rescue to test for exceptions
Change most tests to make use of assert_raise returning the raised
exception rather than relying on a combination of flunk + rescue to
check for exception types/messages.
2013-12-19 09:20:51 -02:00
abhishek
21f0c580f3 duplication removed(DRY) 2013-12-18 16:17:11 +05:30
Guillermo Iguaran
76f8d31046 Merge pull request #13363 from kuldeepaggarwal/f-video-options
allow video_tag to accept `size` as `Number` for square shaped videos
2013-12-17 23:42:05 -08:00
Kuldeep Aggarwal
cd58745a7d allow video_tag to accept size as Number for square shaped videos 2013-12-18 12:24:08 +05:30
David Heinemeier Hansson
c0a2d474c5 Get ready to release 4.1.0.beta1 2013-12-17 16:05:28 -08:00
Jeremy Kemper
cf56dcf930 Fix integration test to pass same-origin verification 2013-12-17 15:04:59 -07:00
Carlos Antonio da Silva
6802196a6b Disable available locales checks to avoid warnings running the tests 2013-12-17 09:05:41 -02:00
Rafael Mendonça França
b34352e425 Merge pull request #13255 from strzalek/bump-builder
Bump up builder
2013-12-12 12:22:21 -08:00
Łukasz Strzałkowski
9f506c494b More liberal builder dependency
Allowing us to get 3.2.x versions if needed.
2013-12-12 20:03:02 +01:00
Godfrey Chan
ebfd97124d Merge pull request #13284 from aayushkhandelwal11/typos_corrected
s/everytime/every time/
2013-12-11 22:13:04 -08:00
Aayush khandelwal
4a9e54ef35 typos rectified [ci skip] 2013-12-12 11:29:23 +05:30
Waynn Lue
93de7ff856 test description uses "disable" when it should be "disabled" 2013-12-11 15:08:53 -08:00
Waynn Lue
b6251d626e value is "disabled" not "disable" 2013-12-11 14:30:41 -08:00
Semyon Perepelitsa
1cd965000b Fix typo in docs, missing colon in Symbol literal [ci skip] 2013-12-11 03:03:49 +08:00
Rafael Mendonça França
a220b1518d Merge pull request #13059 from imkmf/cycle-accepts-array
Cycle object should accept an array

Conflicts:
	actionview/CHANGELOG.md
2013-12-06 17:05:59 -02:00
Kristian Freeman
1eaa521273 A Cycle object should accept an array and cycle through it as it would
with a set of comma-separated objects.
2013-12-06 10:57:37 -08:00
Andriel Nuernberg
ec19c77ca5 Label only accepts :index and :namespace attributes from the input 2013-12-05 20:27:38 -02:00
Rafael Mendonça França
fe13e71162 Remove the explicit order set for the initializer
This will fix the regression added on
b068e20b35797aa6deaa377a48c990759734f515.

See tests added at ff08d31 to a better understanding about the problem
2013-12-05 16:37:10 -02:00
Jeremy Kemper
5086c8c211 Merge pull request #13189 from strzalek/retain-ap-av-dep
Retain ActionPack dependency on ActionView. Fixes #12979.
2013-12-05 07:25:17 -08:00
Shota Fukumori (sora_h)
c1d5477b63 Escalate missing error when :raise is true
Before ec16ba75a5493b9da972eea08bae630eba35b62f,
ActionView::Helpers::TranslationHelper#translate has raised errors with
specifying options[:raise] to true.

This should work by this fix:

     begin
       t(:"translations.missing", raise: true)
     rescue I18n::MissingTranslationData
       p :hello!
     end
2013-12-05 09:20:58 +09:00
Łukasz Strzałkowski
e064658d64 Include AV::Layouts directly in AM::Base
No need to do this in railtie as AM depends on AV either way
2013-12-05 01:03:03 +01:00
Łukasz Strzałkowski
d8888b94b3 Retain ActionPack dependency on ActionView 2013-12-05 01:02:46 +01:00
Godfrey Chan
2c564cdbdb Added \u2028 \u2029 to json_escape 2013-12-04 09:43:42 -08:00
Godfrey Chan
c229c7a39c Use lower case letters in unicodes sequences to match the new encoder's output 2013-12-04 09:27:55 -08:00
Godfrey Chan
2f1c5789c1 Fixed a long-standing bug in json_escape that strips quotation marks 2013-12-04 09:27:54 -08:00
Godfrey Chan
039f9b37b9 Added failing test for json_escape striping quotation marks
Expanded test coverage for html_escape and json_escape
2013-12-04 09:26:14 -08:00
Mario Visic
a156562762 Fix issue where TextHelper#simple_format was calling missing 'raw' method 2013-12-05 00:21:55 +11:00
Rafael Mendonça França
d261c5cc28 Fix documentation of number_to_currency helper
Now users have to explicit mark the unit as safe if they trust it.

Closes #13161

Conflicts:
	actionpack/lib/action_view/helpers/number_helper.rb
	actionpack/test/template/number_helper_i18n_test.rb
2013-12-04 10:27:14 -02:00
Łukasz Strzałkowski
2d3a6a0cb8 Action Pack Variants
By default, variants in the templates will be picked up if a variant is set
and there's a match. The format will be:

  app/views/projects/show.html.erb
  app/views/projects/show.html+tablet.erb
  app/views/projects/show.html+phone.erb

If request.variant = :tablet is set, we'll automatically be rendering the
html+tablet template.

In the controller, we can also tailer to the variants with this syntax:

  class ProjectsController < ActionController::Base
    def show
      respond_to do |format|
        format.html do |html|
          @stars = @project.stars

          html.tablet { @notifications = @project.notifications }
          html.phone  { @chat_heads    = @project.chat_heads }
        end

        format.js
        format.atom
      end
    end
  end

The variant itself is nil by default, but can be set in before filters, like
so:

  class ApplicationController < ActionController::Base
    before_action do
      if request.user_agent =~ /iPad/
        request.variant = :tablet
      end
    end
  end

This is modeled loosely on custom mime types, but it's specifically not
intended to be used together. If you're going to make a custom mime type,
you don't need a variant. Variants are for variations on a single mime
types.
2013-12-04 00:13:16 +01:00
Aaron Patterson
4d648819c5 optimize string literals in erb templates 2013-12-03 14:56:14 -08:00
Rafael Mendonça França
da633f81eb Remove the escaping skip
We are generating safe strings in the paragraph, so we can escape the
tags
2013-12-03 17:26:49 -02:00
Lauro Caetano
b1b9a0aeca Typos. return -> returns. [ci skip] 2013-12-03 13:31:36 -02:00
Michael Koziarski
0c7ac34aed Stop using i18n's built in HTML error handling.
i18n doesn't depend on active support which means it can't use our html_safe
code to do its escaping when generating the spans.  Rather than try to sanitize
the output from i18n, just revert to our old behaviour of rescuing the error
and constructing the tag ourselves.

Fixes: CVE-2013-4491
2013-12-02 16:42:16 -08:00
Michael Koziarski
bea9c9b4c0 Ensure simple_format escapes its html attributes
The previous behavior equated the sanitize option for simple_format with the
escape option of content_tag, however these are two distinct concepts.

This fixes CVE-2013-6416

Conflicts:
	actionview/lib/action_view/helpers/text_helper.rb
2013-12-02 16:42:07 -08:00
Michael Koziarski
b31a7a6f1e Escape the unit value provided to number_to_currency
Previously the unit values were trusted leading to potential XSS vulnerabilities.

Fixes: CVE-2013-6415
2013-12-02 16:41:14 -08:00
Aaron Patterson
2e3c3a87d8 Only use valid mime type symbols as cache keys
CVE-2013-6414
2013-12-02 16:41:09 -08:00
Guillermo Iguaran
b40faf423c Merge pull request #13138 from gsamokovarov/remove-cattr-requires
Remove deprecated cattr_* requires
2013-12-02 14:30:39 -08:00
Genadi Samokovarov
6329d9fa8b Remove deprecated cattr_* requires 2013-12-03 00:28:15 +02:00
Rafael Mendonça França
83e4f33ea1 Make ActionView::Tags loading tread safe 2013-12-02 20:27:50 -02:00
Guillermo Iguaran
152edcc16b activemodel isn't a runtime dependency for actionview 2013-12-02 15:41:16 -05:00
Xavier Noria
d362ee17db Merge pull request #13117 from akshay-vishnoi/typo
Typo and grammatical fixes [ci skip]
2013-12-02 06:17:09 -08:00
Akshay Vishnoi
ef0f633c66 Typo and grammatical fixes [ci skip] 2013-12-02 19:35:02 +05:30
Yves Senn
543ccf740d ActionView::MissingTemplate for partials includes underscore.
Missing partial folder/_partial instead of folder/partial.

Closes #13002.
2013-12-02 08:35:34 +01:00
Kuldeep Aggarwal
fff0309081 unnecessary checking of size with second regex if matched with first one 2013-11-27 15:51:47 +05:30
Akira Matsuda
93c74e1b4d More typo fixes 2013-11-27 03:56:12 +09:00
Akira Matsuda
499b602c8e Minor typo fixes 2013-11-27 02:27:38 +09:00
Carlos Antonio da Silva
b2c7d2345f Revert "Merge pull request #13027 from akshay-vishnoi/f-refactor"
This reverts commit f4a5a9ea4d183f4102796215d4502c46dbe3e52b, reversing
changes made to 7ccb482181ee6c47c765406009018a15172812de.

Reason:

The logic is different, the first call to #option_value_selected? is for
the :selected option (the argument is the "selected" variable), the second
call is for the :disabled option (the argument is the "disabled" variable).
2013-11-25 09:32:32 -02:00
Akshay Vishnoi
0f2ef7b929 avoiding calling of #option_value_selected? two times 2013-11-25 15:36:27 +05:30
Rafael Mendonça França
4f28e54424 _implied_layout_name should be private 2013-11-19 22:55:19 -02:00
Rafael Mendonça França
5487f62741 Use the right indentation 2013-11-19 22:53:32 -02:00
Rafael Mendonça França
ed7e4932f4 Renderer#_render_template should be private
Closes #12831
2013-11-19 22:52:06 -02:00
Mac Martine
6251eb992f Improve readability of sentence in partial-renderer docs [ci skip] 2013-11-19 15:46:00 -08:00
Shimpei Makimoto
1e848906c5 Use set_backtrace instead of @backtrace in ActionView error 2013-11-16 04:41:28 +09:00
Rafael Mendonça França
f6f4bed34d Merge pull request #12853 from joshjordan/master
Allocate one less object using html_safe during content_tag construction
2013-11-15 09:45:14 -08:00
Andrey Ognevsky
d04c4fac3b Take Hash with options inside Array in #url_for 2013-11-15 15:50:42 +04:00
Josh Jordan
ea6640d05d Allocate one less object using html_safe during content_tag construction 2013-11-14 23:51:40 -05:00
David Heinemeier Hansson
07996ebc50 Revert "Used Yield instead of block.call" -- this causes all of atom_feed_helper_test.rb to fail with "SystemStackError: stack level too deep".
This reverts commit d3a1ce1cdc60d593de1682c5f4e3230c8db9a0fd.
2013-11-14 15:31:27 -08:00
Rafael Mendonça França
84961dc5df Merge pull request #12889 from kuldeepaggarwal/speed_ups
Used Yield instead of block.call
2013-11-14 11:29:28 -08:00
Kuldeep Aggarwal
d3a1ce1cdc Used Yield instead of block.call 2013-11-15 00:53:57 +05:30
Saulius Grigaliunas
07d99335b3 Fix syntax error in atom_feed example [ci skip]
Builder's #tag! takes either String or Symbol as the first parameter
2013-11-13 13:56:13 +02:00
Rafael Mendonça França
452d746006 Make the method name the first argument
This is the only argument that changes over the method calls so it is
better to it be the first one
2013-11-09 18:28:32 -02:00
Rafael Mendonça França
87d0bde03f Drop one more string allocation 2013-11-09 18:28:32 -02:00