# Import external modules import base64 import json import logging import re # Import app modules from configuration import const as conf from constants import Constants # Constants const = Constants() const.COOKIE_NAME = 'C' const.COOKIE_NAME_FOR_JAVASCRIPT = 'J' # Returns cookieData:map[name->value] def getCookieData(httpRequest): if conf.isDev: logging.debug('getCookieData() httpRequest.cookies=' + str(httpRequest.cookies)) cookieBase64 = httpRequest.cookies.get(const.COOKIE_NAME) cookieBase64 = cookieBase64.encode( 'ascii') if cookieBase64 else None # Only allow ASCII 128-bit range if conf.isDev: logging.debug('getCookieData() cookieBase64=' + str(cookieBase64)) cookieJson = base64.urlsafe_b64decode( cookieBase64 ) if cookieBase64 else None # Discards non-base-64 characters if conf.isDev: