angular_xss 0.4.0 → 1.0.0

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.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/test.yml +19 -9
  3. data/.ruby-version +1 -1
  4. data/CHANGELOG.md +20 -1
  5. data/Gemfile +1 -1
  6. data/Gemfile.lock +1 -1
  7. data/{Gemfile.rails-3.2 → Gemfile.rails-3.2.haml-4} +1 -1
  8. data/{Gemfile.rails-3.2.lock → Gemfile.rails-3.2.haml-4.lock} +4 -4
  9. data/Gemfile.rails-4.2.haml-4 +1 -1
  10. data/Gemfile.rails-4.2.haml-4.lock +4 -4
  11. data/Gemfile.rails-4.2.haml-5 +1 -1
  12. data/Gemfile.rails-4.2.haml-5.lock +4 -4
  13. data/Gemfile.rails-5.1.haml-4 +1 -1
  14. data/Gemfile.rails-5.1.haml-4.lock +8 -6
  15. data/Gemfile.rails-5.1.haml-5 +1 -1
  16. data/Gemfile.rails-5.1.haml-5.lock +9 -7
  17. data/Gemfile.rails-6.1.haml-5 +1 -1
  18. data/Gemfile.rails-6.1.haml-5.lock +3 -3
  19. data/Gemfile.rails-7.0.haml-5 +8 -0
  20. data/Gemfile.rails-7.0.haml-5.lock +88 -0
  21. data/Gemfile.rails-7.1.haml-5 +9 -0
  22. data/Gemfile.rails-7.1.haml-5.lock +105 -0
  23. data/Gemfile.rails-7.1.haml-6 +9 -0
  24. data/Gemfile.rails-7.1.haml-6.lock +122 -0
  25. data/README.md +11 -2
  26. data/angular_xss.gemspec +1 -0
  27. data/lib/angular_xss/erb.rb +17 -27
  28. data/lib/angular_xss/escaper.rb +8 -0
  29. data/lib/angular_xss/haml.rb +25 -19
  30. data/lib/angular_xss/output_buffer.rb +25 -0
  31. data/lib/angular_xss/safe_buffer.rb +31 -7
  32. data/lib/angular_xss/version.rb +1 -1
  33. data/lib/angular_xss.rb +1 -0
  34. data/spec/angular_xss/erb_spec.rb +46 -3
  35. data/spec/angular_xss/escaper_spec.rb +21 -0
  36. data/spec/angular_xss/haml_spec.rb +0 -2
  37. data/spec/angular_xss/output_buffer_spec.rb +45 -0
  38. data/spec/angular_xss/safe_buffer_spec.rb +16 -4
  39. data/spec/spec_helper.rb +5 -11
  40. data/spec/support/engine_preventing_angular_xss.rb +21 -17
  41. data/spec/templates/_test_erb.erb +14 -5
  42. data/spec/templates/_test_haml.haml +40 -23
  43. metadata +18 -6
@@ -1,14 +1,23 @@
1
- <%= "{{unsafe}}" %>
2
- <%= "{{safe}}".html_safe %>
1
+ <%- unsafe_string = '{{unsafe}}' %>
2
+ <%- safe_string = '{{safe}}'.html_safe %>
3
+
4
+ <%= unsafe_string %>
5
+ <%= safe_string %>
6
+
7
+ <%= ''.html_safe + unsafe_string %>
8
+ <%= ''.html_safe + safe_string %>
9
+
10
+ <%= ''.html_safe << unsafe_string %>
11
+ <%= ''.html_safe << safe_string %>
3
12
 
4
13
  {{safe}}
5
14
 
6
- <div foo="{{safe}}" bar="<%= '{{unsafe}}' %>">
15
+ <div foo="{{safe}}" bar="<%= unsafe_string %>">
7
16
  {{safe}}
8
17
  </div>
9
18
 
10
- <%= content_tag(:span, '{{unsafe}}') %>
11
- <%= content_tag(:span, '{{safe}}'.html_safe) %>
19
+ <%= content_tag(:span, unsafe_string) %>
20
+ <%= content_tag(:span, safe_string) %>
12
21
 
13
22
  <%= '{&lcub;unsafe}}' %>
14
23
  <%= '{&lbrace;unsafe}}' %>
@@ -1,11 +1,46 @@
1
- = "{{unsafe}}"
2
- #{'{{unsafe}}'}
3
- = "{{safe}}".html_safe
1
+ -# HTML attributes and static string interpolation in Haml work in different ways:
2
+ -# 1. Under certain conditions, attributes are precompiled.
3
+ -# We never have to escape those because they can not contain user input.
4
+ -# 2. Whenever there is a Ruby call on attributes, Haml will have to evaluate
5
+ -# them at runtime. Since they can contain user input, XSS logic applies.
6
+
7
+ -# precompiled (static)
8
+ - if Gem::Version.new(Haml::VERSION) >= Gem::Version.new(6)
9
+ -# HAML 6 is smart enough to recognize static strings and will not
10
+ -# escape it - so neither do we
11
+ #{'{{safe}}'}
12
+ = "{{safe}}"
13
+ - else
14
+ #{'{{unsafe}}'}
15
+ = "{{unsafe}}"
4
16
 
5
17
  {{safe}}
18
+ %div(foo='{{safe}}')
19
+ %div{:class => '{{safe}}', :id => '{{safe}}'}
20
+
21
+ -# Compiled at runtime:
22
+ - unsafe_evaluated_variable = '{{unsafe}}'
23
+ - safe_evaluated_variable = '{{safe}}'.html_safe
24
+
25
+ = unsafe_evaluated_variable
26
+ = safe_evaluated_variable
27
+
28
+ #{unsafe_evaluated_variable}
29
+ #{safe_evaluated_variable}
30
+
31
+ = ''.html_safe + unsafe_evaluated_variable
32
+ = ''.html_safe + safe_evaluated_variable
33
+
34
+ = ''.html_safe << unsafe_evaluated_variable
35
+ = ''.html_safe << safe_evaluated_variable
6
36
 
7
- = content_tag(:span, '{{unsafe}}')
8
- = content_tag(:span, '{{safe}}'.html_safe)
37
+ = content_tag(:span, unsafe_evaluated_variable)
38
+ = content_tag(:span, safe_evaluated_variable)
39
+
40
+ %div{:class => unsafe_evaluated_variable, :id => unsafe_evaluated_variable}
41
+ %div(bar="#{unsafe_evaluated_variable}")
42
+ %div{:foo => safe_evaluated_variable, :bar => unsafe_evaluated_variable}
43
+ {{safe}}
9
44
 
10
45
  = '{&lcub;unsafe}}'
11
46
  = '{&lbrace;unsafe}}'
@@ -17,21 +52,3 @@
17
52
  = '{&#000000123;unsafe}}'
18
53
  = '{&#0000000000000123;unsafe}}'
19
54
  = '&lcub;&#x7b;unsafe}}'
20
-
21
- -# HTML attributes in Haml work in different ways:
22
- -# 1. Under certain conditions, attributes are precompiled.
23
- -# We never have to escape those because they can not contain user input.
24
- -# 2. Whenever there is a Ruby call on attributes, Haml will have to evaluate
25
- -# them at runtime. Since they can contain user input, XSS logic applies.
26
-
27
- -# Precompiled:
28
- %div(foo='{{safe}}')
29
- %div{:class => '{{safe}}', :id => '{{safe}}'}
30
-
31
- -# Compiled at runtime:
32
- - unsafe = '{{unsafe}}'
33
- - safe = '{{safe}}'.html_safe
34
- %div{:class => unsafe, :id => unsafe}
35
- %div(bar="#{unsafe}")
36
- %div{:foo => safe, :bar => unsafe}
37
- {{safe}}
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: angular_xss
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henning Koch
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-23 00:00:00.000000000 Z
11
+ date: 2024-07-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -52,8 +52,8 @@ files:
52
52
  - CHANGELOG.md
53
53
  - Gemfile
54
54
  - Gemfile.lock
55
- - Gemfile.rails-3.2
56
- - Gemfile.rails-3.2.lock
55
+ - Gemfile.rails-3.2.haml-4
56
+ - Gemfile.rails-3.2.haml-4.lock
57
57
  - Gemfile.rails-4.2.haml-4
58
58
  - Gemfile.rails-4.2.haml-4.lock
59
59
  - Gemfile.rails-4.2.haml-5
@@ -64,6 +64,12 @@ files:
64
64
  - Gemfile.rails-5.1.haml-5.lock
65
65
  - Gemfile.rails-6.1.haml-5
66
66
  - Gemfile.rails-6.1.haml-5.lock
67
+ - Gemfile.rails-7.0.haml-5
68
+ - Gemfile.rails-7.0.haml-5.lock
69
+ - Gemfile.rails-7.1.haml-5
70
+ - Gemfile.rails-7.1.haml-5.lock
71
+ - Gemfile.rails-7.1.haml-6
72
+ - Gemfile.rails-7.1.haml-6.lock
67
73
  - LICENSE
68
74
  - README.md
69
75
  - Rakefile
@@ -73,10 +79,13 @@ files:
73
79
  - lib/angular_xss/erb.rb
74
80
  - lib/angular_xss/escaper.rb
75
81
  - lib/angular_xss/haml.rb
82
+ - lib/angular_xss/output_buffer.rb
76
83
  - lib/angular_xss/safe_buffer.rb
77
84
  - lib/angular_xss/version.rb
78
85
  - spec/angular_xss/erb_spec.rb
86
+ - spec/angular_xss/escaper_spec.rb
79
87
  - spec/angular_xss/haml_spec.rb
88
+ - spec/angular_xss/output_buffer_spec.rb
80
89
  - spec/angular_xss/safe_buffer_spec.rb
81
90
  - spec/spec_helper.rb
82
91
  - spec/support/engine_preventing_angular_xss.rb
@@ -85,7 +94,8 @@ files:
85
94
  homepage: https://github.com/makandra/angular_xss
86
95
  licenses:
87
96
  - MIT
88
- metadata: {}
97
+ metadata:
98
+ rubygems_mfa_required: 'true'
89
99
  post_install_message:
90
100
  rdoc_options: []
91
101
  require_paths:
@@ -101,14 +111,16 @@ required_rubygems_version: !ruby/object:Gem::Requirement
101
111
  - !ruby/object:Gem::Version
102
112
  version: '0'
103
113
  requirements: []
104
- rubygems_version: 3.1.4
114
+ rubygems_version: 3.5.13
105
115
  signing_key:
106
116
  specification_version: 4
107
117
  summary: Patches rails_xss and Haml so AngularJS interpolations are auto-escaped in
108
118
  unsafe strings.
109
119
  test_files:
110
120
  - spec/angular_xss/erb_spec.rb
121
+ - spec/angular_xss/escaper_spec.rb
111
122
  - spec/angular_xss/haml_spec.rb
123
+ - spec/angular_xss/output_buffer_spec.rb
112
124
  - spec/angular_xss/safe_buffer_spec.rb
113
125
  - spec/spec_helper.rb
114
126
  - spec/support/engine_preventing_angular_xss.rb