Skip to content

Commit e86a489

Browse files
committed
Escape single and double quotes, always
Signed-off-by: Ivan Kanakarakis <[email protected]>
1 parent 80ec58d commit e86a489

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/saml2/pack.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@
6868
</html>"""
6969

7070

71+
def _html_escape(payload):
72+
return html.escape(payload, quote=True)
73+
74+
7175
def http_form_post_message(message, location, relay_state="",
7276
typ="SAMLRequest", **kwargs):
7377
"""The HTTP POST binding defines a mechanism by which SAML protocol
@@ -91,15 +95,15 @@ def http_form_post_message(message, location, relay_state="",
9195
_msg = _msg.decode('ascii')
9296

9397
saml_response_input = HTML_INPUT_ELEMENT_SPEC.format(
94-
name=html.escape(typ),
95-
val=html.escape(_msg),
98+
name=_html_escape(typ),
99+
val=_html_escape(_msg),
96100
type='hidden')
97101

98102
relay_state_input = ""
99103
if relay_state:
100104
relay_state_input = HTML_INPUT_ELEMENT_SPEC.format(
101105
name='RelayState',
102-
val=html.escape(relay_state),
106+
val=_html_escape(relay_state),
103107
type='hidden')
104108

105109
response = HTML_FORM_SPEC.format(

0 commit comments

Comments
 (0)