Commit Graph

16 Commits

Author SHA1 Message Date
Javi Martín
7bf4e4d611 Sanitize descriptions in the views
Sanitizing descriptions before saving a record has a few drawbacks:

1. It makes the application rely on data being safe in the database. If
somehow dangerous data enters the database, the application will be
vulnerable to XSS attacks
2. It makes the code complicated
3. It isn't backwards compatible; if we decide to disallow a certain
HTML tag in the future, we'd need to sanitize existing data.

On the other hand, sanitizing the data in the view means we don't need
to triple-check dangerous HTML has already been stripped when we see the
method `auto_link_already_sanitized_html`, since now every time we use
it we sanitize the text in the same line we call this method.

We could also sanitize the data twice, both when saving to the database
and when displaying values in the view. However, doing so wouldn't make
the application safer, since we sanitize text introduced through
textarea fields but we don't sanitize text introduced through input
fields.

Finally, we could also overwrite the `description` method so it
sanitizes the text. But we're already introducing Globalize which
overwrites that method, and overwriting it again is a bit too confusing
in my humble opinion. It can also lead to hard-to-debug behaviour.
2019-10-21 21:32:02 +02:00
Javi Martín
871fa020a5 Add and apply ParenthesesAsGroupedExpression rule 2019-10-05 15:03:26 +02:00
Javi Martín
70a07c095f Add and apply Style/BlockDelimiters rubocop rule
We were already using it most of the time, but there were a few places
were we used brackets for multiline blocks.
2019-10-05 14:44:14 +02:00
Javi Martín
66334b5757 Add globalizable tests for all translatable models
So now we test in depth at the model level, and can be a bit more
relaxed about integration tests for translations.

Note we're defining some extra factories to make sure all translatable
attributes with presence validation rules are mandatory. This way we can
simplify the way we obtain required fields, using `required_attribute?`.
Otherwise, fields having an `unless` condition in their presence
validation rules would count as mandatory even when they're not.
2019-09-23 18:01:44 +02:00
Javi Martín
f9ed186909 Add rubocop spacing rules
We were following these rules in most places; we just didn't define them
anywhere.
2019-09-10 21:04:56 +02:00
Javi Martín
a21240b230 Use Date.current and Time.current
Using Date.today and Time.now might lead to inconsistencies if the time
zone the application uses is not the same as the system time zone.
2019-08-28 20:32:40 +02:00
Javi Martín
2215971a6b Remove unused code 2019-05-21 13:50:18 +02:00
Julian Herrero
31ac8b7f55 Change single quotes to double quotes 2019-02-15 11:40:39 +01:00
Javi Martín
f2bebca6be Bring back and fix deleted test
It was removed in 755be96 because some tags were allowed, but we can
just update it to check it doesn't remove those tags.
2018-09-12 12:35:28 +02:00
Raúl Fuentes
bf0472fd58 Fix test
now the <a> tag is permited, also the list of allowed tags is in
the configuration of ckeditor4
2018-09-12 12:35:28 +02:00
iagirre
c37496601c Budget and phases specs updated (model specs) to include the new 'Information' phase 2018-01-23 15:42:01 +01:00
Bertocq
313d8d2e11 Adjust date ranges of prev/next phases when enabling/disabling a Budget::Phase, with model specs 2018-01-16 15:20:18 +01:00
Bertocq
601351d160 Validate next/prev phases before saving a Budget::Phase, with model specs 2018-01-16 15:20:17 +01:00
Bertocq
d505cda949 Add description sanitization to Budget::Phase with model specs 2018-01-16 12:18:13 +01:00
Bertocq
21b62106e5 Add next/prev enabled phase helper functions to Budget::Phase with model specs 2018-01-16 12:18:13 +01:00
Bertocq
36e74d0ef2 Add Budget::Phase model, spec and factory
Create a new Budget::Phase model that:
* Stablishes a relation with its budget
* Stablishes relation with two other Budget::Phases (previous and next)
* Validates basic dates range, kind and description rules.
* Adds scopes to get the ones enabled as well as each individual phase

Create a factory that generates a basic and valid Budget::Phase

Create a model spec that checks kind, date range and budget validations.
2018-01-16 12:18:13 +01:00