File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed
Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -119,6 +119,19 @@ cdef class Cookie:
119119 return CefToPyString(cefString)
120120
121121 cpdef py_void SetDomain(self , py_string domain):
122+ pattern = re.compile(r " ^ (?: [a-z0-9 ](?: [a-z0-9-_ ]{0,61} [a-z0-9 ]) ? \. ) "
123+ r " + [a-z0-9 ][a-z0-9-_ ]{0,61} [a-z ]$ " )
124+ if PY_MAJOR_VERSION == 2 :
125+ assert isinstance (domain, bytes), " domain type is not bytes"
126+ domain = domain.decode(g_applicationSettings[" string_encoding" ],
127+ errors = BYTES_DECODE_ERRORS)
128+ try :
129+ if not pattern.match(domain.encode(" idna" ).decode(" ascii" )):
130+ raise Exception (" Cookie.SetDomain() failed, invalid domain: {0}"
131+ .format(domain))
132+ except UnicodeError :
133+ raise Exception (" Cookie.SetDomain() failed, invalid domain: {0}"
134+ .format(domain))
122135 cdef CefString cefString
123136 cefString.Attach(& self .cefCookie.domain, False )
124137 PyToCefString(domain, cefString)
You can’t perform that action at this time.
0 commit comments