push
0 of 1 new or added line in 1 file covered. (0.0%)
6774 existing lines in 129 files now uncovered.1939 of 15613 relevant lines covered (12.42%)
0.25 hits per line
1 |
module SecurityHelper |
1✔ |
2 |
def special_chars |
1✔ |
UNCOV
3
|
special = '/\\?<>|&$#'
|
× |
UNCOV
4
|
special |
× |
5 |
end
|
|
6 |
|
|
7 |
def contains_special_chars?(str) |
1✔ |
UNCOV
8
|
special = special_chars |
× |
UNCOV
9
|
regex = /[#{special.gsub(/./) { |char| "\\#{char}" }}]/
|
× |
10 |
|
|
UNCOV
11
|
!(str =~ regex).nil? |
× |
12 |
end
|
|
13 |
|
|
14 |
def warn_for_special_chars(str, field_name) |
1✔ |
UNCOV
15
|
if contains_special_chars? str
|
× |
16 |
flash[:error] = field_name + " must not contain special characters '" + special_chars + "'." |
× |
17 |
return true |
× |
18 |
end
|
|
UNCOV
19
|
false
|
× |
20 |
end
|
|
21 |
|
|
22 |
def json_valid?(str) |
1✔ |
23 |
JSON.parse(str)
|
× |
24 |
true
|
× |
25 |
rescue JSON::ParserError, TypeError |
|
26 |
false
|
× |
27 |
end
|
|
28 |
|
|
29 |
def date_valid?(date) |
1✔ |
30 |
Date.parse(date)
|
× |
31 |
true
|
× |
32 |
rescue ArgumentError |
|
33 |
false
|
× |
34 |
end
|
|
35 |
end
|