Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
O
OHR Support
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
97
Issues
97
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
OHR Support
Commits
4656cf1c
Commit
4656cf1c
authored
Dec 17, 2011
by
Holger Just
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Escape raw input if there is a Liquid syntax error
parent
d2ccdc88
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
5 deletions
+22
-5
application_helper.rb
app/helpers/application_helper.rb
+12
-5
liquid_test.rb
test/unit/lib/chili_project/liquid_test.rb
+10
-0
No files found.
app/helpers/application_helper.rb
View file @
4656cf1c
...
...
@@ -446,20 +446,20 @@ module ApplicationHelper
case
args
.
size
when
1
obj
=
options
[
:object
]
text
=
args
.
shift
input_
text
=
args
.
shift
when
2
obj
=
args
.
shift
attr
=
args
.
shift
text
=
obj
.
send
(
attr
).
to_s
input_
text
=
obj
.
send
(
attr
).
to_s
else
raise
ArgumentError
,
'invalid arguments to textilizable'
end
return
''
if
text
.
blank?
return
''
if
input_
text
.
blank?
project
=
options
[
:project
]
||
@project
||
(
obj
&&
obj
.
respond_to?
(
:project
)
?
obj
.
project
:
nil
)
only_path
=
options
.
delete
(
:only_path
)
==
false
?
false
:
true
begin
text
=
ChiliProject
::
Liquid
::
Legacy
.
run_macros
(
text
)
text
=
ChiliProject
::
Liquid
::
Legacy
.
run_macros
(
input_
text
)
liquid_template
=
ChiliProject
::
Liquid
::
Template
.
parse
(
text
)
liquid_variables
=
get_view_instance_variables_for_liquid
liquid_variables
.
merge!
({
'current_user'
=>
User
.
current
})
...
...
@@ -478,8 +478,15 @@ module ApplicationHelper
end
Rails
.
logger
.
debug
msg
end
rescue
Liquid
::
SyntaxError
rescue
Liquid
::
SyntaxError
=>
exception
if
Rails
.
logger
&&
Rails
.
logger
.
debug?
msg
=
"[Liquid Syntax Error]
#{
exception
.
message
}
\n
:
\n
#{
exception
.
backtrace
.
join
(
"
\n
"
)
}
"
msg
<<
"
\n\n
"
Rails
.
logger
.
debug
msg
end
# Skip Liquid if there is a syntax error
text
=
h
(
input_text
)
end
@parsed_headings
=
[]
...
...
test/unit/lib/chili_project/liquid_test.rb
View file @
4656cf1c
...
...
@@ -208,4 +208,14 @@ class ChiliProject::LiquidTest < ActionView::TestCase
end
end
end
context
"invalid input"
do
should
"be escaped"
do
text
=
"{% --- something invalid %}
\n
"
text
<<
'<script>alert("Hello")</script>'
formatted
=
textilizable
(
text
)
assert_match
'<script>alert("Hello")</script>'
,
formatted
end
end
end
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