Skip to content

Commit be12131

Browse files
authored
Merge branch 'develop' into elasticsearch4
2 parents ce99d54 + 07fc9a2 commit be12131

File tree

4 files changed

+11
-3
lines changed

4 files changed

+11
-3
lines changed

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
FROM amazonlinux:1
1+
FROM amazonlinux:2018.03.0.20180424
2+
23

34
WORKDIR /workdir
45
COPY requirements.txt ./

api-template.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -906,6 +906,9 @@ Resources:
906906
required: true
907907
schema:
908908
$ref: '#/definitions/MeArticlesDraftsCreate'
909+
responses:
910+
'200':
911+
description: 'successful operation'
909912
security:
910913
- cognitoUserPool: []
911914
x-amazon-apigateway-integration:

src/common/text_sanitizer.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ def allow_div_attributes(tag, name, value):
3535
return True
3636
if name == 'data-alis-iframely-url':
3737
p = urlparse(value)
38-
return p.netloc == 'twitter.com'
38+
is_url = len(p.scheme) > 0 and len(p.netloc) > 0
39+
is_clean = True if bleach.clean(value) == value else False
40+
return is_url and is_clean
3941
if name == 'contenteditable':
4042
if value == 'false':
4143
return True

tests/common/test_text_sanitizer.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ def test_sanitize_article_body(self):
6868
</div>
6969
<a href="http://example.com">link</a>
7070
<div data-alis-iframely-url="https://twitter.com/hoge">hoge</div>
71+
<div data-alis-iframely-url="https://example.com/hoge?x=1">hoge</div>
72+
<div data-alis-iframely-url="http://example.com/hoge?x=1%3Cdiv%3Ehoge%3C%2Fdiv%3E">hoge</div>
7173
'''.format(domain=os.environ['DOMAIN'])
7274

7375
result = TextSanitizer.sanitize_article_body(target_html)
@@ -143,7 +145,7 @@ def test_sanitize_article_body_with_div_unauthorized_url(self):
143145
target_html = '''
144146
<h2>sample h2</h2>
145147
<div class='hoge piyo' data='aaa' contenteditable='true'></div>
146-
<div data-alis-iframely-url="https://example.com/hoge">hoge</div>
148+
<div data-alis-iframely-url="https://example.com/hoge?<script>piyo</script>">hoge</div>
147149
'''
148150

149151
expected_html = '''

0 commit comments

Comments
 (0)