Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
b5a674d9
Commit
b5a674d9
authored
Apr 12, 2016
by
Robert Raposa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix parsing defect
parent
f9ab191c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
3 deletions
+14
-3
scripts/safe_template_linter.py
+10
-3
scripts/tests/test_safe_template_linter.py
+4
-0
No files found.
scripts/safe_template_linter.py
View file @
b5a674d9
...
@@ -874,8 +874,8 @@ class MakoTemplateLinter(object):
...
@@ -874,8 +874,8 @@ class MakoTemplateLinter(object):
filters
=
filters_match
.
group
()[
1
:
-
1
]
.
replace
(
" "
,
""
)
.
split
(
","
)
filters
=
filters_match
.
group
()[
1
:
-
1
]
.
replace
(
" "
,
""
)
.
split
(
","
)
if
(
len
(
filters
)
==
2
)
and
(
filters
[
0
]
==
'n'
)
and
(
filters
[
1
]
==
'unicode'
):
if
(
len
(
filters
)
==
2
)
and
(
filters
[
0
]
==
'n'
)
and
(
filters
[
1
]
==
'unicode'
):
# {x | n, unicode} is valid in any context
# {x | n, unicode} is valid in any context
pass
pass
elif
context
==
'html'
:
elif
context
==
'html'
:
if
(
len
(
filters
)
==
1
)
and
(
filters
[
0
]
==
'h'
):
if
(
len
(
filters
)
==
1
)
and
(
filters
[
0
]
==
'h'
):
if
has_page_default
:
if
has_page_default
:
...
@@ -1053,7 +1053,14 @@ class MakoTemplateLinter(object):
...
@@ -1053,7 +1053,14 @@ class MakoTemplateLinter(object):
open_char_index
=
template
.
find
(
open_char
,
start_index
,
close_char_index
)
open_char_index
=
template
.
find
(
open_char
,
start_index
,
close_char_index
)
parse_string
=
ParseString
(
template
,
start_index
,
close_char_index
)
parse_string
=
ParseString
(
template
,
start_index
,
close_char_index
)
valid_index_list
=
[
close_char_index
]
if
0
<=
open_char_index
:
valid_index_list
.
append
(
open_char_index
)
if
0
<=
parse_string
.
start_index
:
if
0
<=
parse_string
.
start_index
:
valid_index_list
.
append
(
parse_string
.
start_index
)
min_valid_index
=
min
(
valid_index_list
)
if
parse_string
.
start_index
==
min_valid_index
:
strings
.
append
(
parse_string
)
strings
.
append
(
parse_string
)
if
parse_string
.
end_index
<
0
:
if
parse_string
.
end_index
<
0
:
return
unparseable_result
return
unparseable_result
...
@@ -1063,7 +1070,7 @@ class MakoTemplateLinter(object):
...
@@ -1063,7 +1070,7 @@ class MakoTemplateLinter(object):
num_open_chars
=
num_open_chars
,
strings
=
strings
num_open_chars
=
num_open_chars
,
strings
=
strings
)
)
if
0
<=
open_char_index
<
close_char
_index
:
if
open_char_index
==
min_valid
_index
:
if
start_delim
is
not
None
:
if
start_delim
is
not
None
:
# if we find another starting delim, consider this unparseable
# if we find another starting delim, consider this unparseable
start_delim_index
=
template
.
find
(
start_delim
,
start_index
,
close_char_index
)
start_delim_index
=
template
.
find
(
start_delim
,
start_index
,
close_char_index
)
...
...
scripts/tests/test_safe_template_linter.py
View file @
b5a674d9
...
@@ -248,6 +248,10 @@ class TestMakoTemplateLinter(TestCase):
...
@@ -248,6 +248,10 @@ class TestMakoTemplateLinter(TestCase):
'rule'
:
None
'rule'
:
None
},
},
{
{
'expression'
:
"${HTML(render_entry(map['entries'], child))}"
,
'rule'
:
None
},
{
'expression'
:
"${ HTML('<span></span>') + 'some other text' }"
,
'expression'
:
"${ HTML('<span></span>') + 'some other text' }"
,
'rule'
:
Rules
.
mako_html_alone
'rule'
:
Rules
.
mako_html_alone
},
},
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment