From ca05c3bed6bf4d99d8aebec35edc0d276a87bbc8 Mon Sep 17 00:00:00 2001 From: Christopher Harrison Date: Mon, 4 Sep 2017 17:16:27 +0100 Subject: [PATCH] The whitespace between an authentication method and its metadata is not optional --- irobot/authentication/parser.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/irobot/authentication/parser.py b/irobot/authentication/parser.py index 594ebb9..77c1c57 100644 --- a/irobot/authentication/parser.py +++ b/irobot/authentication/parser.py @@ -26,7 +26,7 @@ # per RFC7235: https://tools.ietf.org/html/rfc7235#section-2.1 # # AUTH_HANDLERS := AUTH_HANDLER *( OWS "," OWS AUTH_HANDLER ) -# AUTH_HANDLER := TOKEN [ OWS ( TOKEN68 / PARAMS ) ] +# AUTH_HANDLER := TOKEN [ 1*SP ( TOKEN68 / PARAMS ) ] # PARAMS := PARAM ( OWS "," OWS PARAM )* # PARAM := TOKEN OWS "=" OWS ( TOKEN / QUOTED_STRING ) # TOKEN := 1*( ALPHA / DIGIT / "!" / "#" / "$" / "%" / "&" / "'" / "*" / "+" / "-" / "." / "^" / "_" / "`" / "|" / "~" ) @@ -37,7 +37,8 @@ # QUOTE := %x22 # ALPHA := %x41-5A / %x61-7A # DIGIT := %x30-39 -# OWS := *( %x09 / %x20 ) +# OWS := *SP +# SP := %x09 / %x20 class ParseError(Exception): @@ -149,6 +150,7 @@ def _parser(s:str) -> _ParseT: return _parser +_WS = _terminal(re.compile(r"[\t ]+")) _OWS = _terminal(re.compile(r"[\t ]*")) _DIGIT = _terminal(re.compile(r"[0-9]")) _ALPHA = _terminal(re.compile(r"[a-zA-Z]")) @@ -302,7 +304,7 @@ def _auth_handler(s:str) -> Tuple[AuthHandler, str]: except ParseError: # There's no list separator, so there must be a payload/parameters - _, remainder = _OWS(remainder) + _, remainder = _WS(remainder) try: params, remainder = _params(remainder)