File tree Expand file tree Collapse file tree 4 files changed +11
-5
lines changed Expand file tree Collapse file tree 4 files changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -48,6 +48,13 @@ def page_lang(lang)
48
48
lang . empty? ? 'ja' : lang
49
49
end
50
50
51
+ def sanitize_content ( content )
52
+ sanitize ( content ,
53
+ tags : ActionView ::Base . sanitized_allowed_tags + [ 'center' ] ,
54
+ attributes : ActionView ::Base . sanitized_allowed_attributes + [ 'id' ]
55
+ )
56
+ end
57
+
51
58
# 'inline_' プレフィックスがついたflashメッセージをビュー内で表示するヘルパー
52
59
# inline_alert → alert, inline_warning → warning のように変換してBootstrapのCSSクラスを適用
53
60
def render_inline_flash_messages
Original file line number Diff line number Diff line change 9
9
10
10
< div class ='container ' style ='line-height: 1.9em; '>
11
11
< section class ='doc ' style ='padding: 50px 0px 100px 0px; '>
12
- <%= raw @content %>
12
+ <%= sanitize_content ( @content ) %>
13
13
</ section >
14
14
15
15
<% if request . path . start_with? '/docs' %>
22
22
<%= render 'shared/social_buttons' %>
23
23
</ section >
24
24
</ div >
25
-
26
-
Original file line number Diff line number Diff line change 36
36
37
37
< iframe class ="lazyload " src ="https://anchor.fm/coderdojo-japan/embed/episodes/ <%= @episode . permalink %> " width ="100% " scrolling ="no " frameborder ="yes " style ='margin-bottom: 30px; '> </ iframe >
38
38
39
- <%= raw Rinku . auto_link ( @content ) %>
39
+ <%= sanitize_content ( Rinku . auto_link ( @content ) ) %>
40
40
</ div >
41
41
</ section >
42
42
Original file line number Diff line number Diff line change 14
14
get doc_path ( param )
15
15
doc = Document . new ( param )
16
16
expected = Kramdown ::Document . new ( doc . content , input : 'GFM' ) . to_html
17
+ expected = ApplicationController . helpers . sanitize_content ( expected )
17
18
expect ( response . body ) . to include ( expected . strip )
18
19
end
19
20
23
24
expect ( response . status ) . to eq 302
24
25
end
25
26
end
26
- end
27
+ end
You can’t perform that action at this time.
0 commit comments