Skip to content

Commit 8f15972

Browse files
committed
renamed raw component
1 parent 14a74ae commit 8f15972

File tree

5 files changed

+10
-41
lines changed

5 files changed

+10
-41
lines changed

CHANGELOG.md

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -6,37 +6,6 @@
66

77
[Solved Issues](https://github.com/basemate/matestack-ui-core/issues?q=is%3Aissue+is%3Aclosed+milestone%3A0.7.4)
88

9-
10-
### Security Fixes
11-
12-
XSS/Script Injection
13-
14-
--> until 0.7.3, matestack-ui-core is vulnerable to XSS/Script injection due to missing string escaping
15-
--> this is especially dangerous, if you render a string which was submitted via a form through `plain` or any other string rendering such as `heading size: 1, text: "..."`
16-
--> fixed in 0.7.4, please update immediately
17-
18-
```ruby
19-
class Pages::MyApp::MyExamplePage < Matestack::Ui::Page
20-
21-
class FakeUser < Struct.new(:name)
22-
end
23-
24-
def prepare
25-
@user = FakeUser.new("<script>alert('such hack many wow')</script>")
26-
end
27-
28-
def response
29-
components {
30-
div do
31-
heading size: 1, text: "Hello #{@user.name}" # is not escaped
32-
plain "Hello #{@user.name}" # is not escaped
33-
end
34-
}
35-
end
36-
end
37-
38-
```
39-
409
### Improvements
4110

4211
* On form submit, matestack form values are reset to previous values by fiedl

app/concepts/matestack/ui/core/raw/raw.rb

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module Matestack::Ui::Core::Unescaped
2+
class Unescaped < Matestack::Ui::Core::Component::Static
3+
def show
4+
@argument
5+
end
6+
end
7+
end

spec/usage/base/xss_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def response
6969

7070
visit "/example"
7171

72-
expect(page.html).to include("id=\"something-&quot;><script>alert('hello');</script>")
72+
expect(page.html).to include("id=\"something-&quot;&gt;&lt;script&gt;alert('hello');&lt;/script&gt;")
7373
end
7474
end
7575
end

spec/usage/components/rawhtml_spec.rb renamed to spec/usage/components/unescaped_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
describe "Raw Html Component", type: :feature, js: true do
1+
describe "Unescaped Component", type: :feature, js: true do
22

33
it "allows the insertion of pure HTML: Example 1" do
44

55
class ExamplePage < Matestack::Ui::Page
66
def response
77
components {
8-
rawhtml <<~HTML
8+
unescaped <<~HTML
99
<h1>Hello World</h1>
1010
<script>alert('Really Hello!')</script>
1111
HTML

0 commit comments

Comments
 (0)