mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
better error essage when iframe receives unexpected encrypted message
This commit is contained in:
parent
416fa04d3b
commit
d8671c8e9e
@ -173,14 +173,17 @@ def create_wrapped_iframe(handlers, bootstrap_text, entry_point, kw):
|
|||||||
return iframe, ans
|
return iframe, ans
|
||||||
|
|
||||||
|
|
||||||
client_instance_num = 0
|
instance_numbers = {}
|
||||||
|
|
||||||
class IframeClient:
|
class IframeClient:
|
||||||
|
|
||||||
def __init__(self, handlers, name):
|
def __init__(self, handlers, name):
|
||||||
self.encrypted_communications = False
|
self.encrypted_communications = False
|
||||||
self.name = name
|
self.name = name
|
||||||
self.instance_num = v'++client_instance_num'
|
if not instance_numbers[self.name]:
|
||||||
|
instance_numbers[self.name] = 0
|
||||||
|
instance_numbers[self.name] += 1
|
||||||
|
self.instance_num = instance_numbers[self.name]
|
||||||
self.handlers = {k: handlers[k] for k in handlers}
|
self.handlers = {k: handlers[k] for k in handlers}
|
||||||
self.initialize_handler = handlers.initialize
|
self.initialize_handler = handlers.initialize
|
||||||
self.handlers.initialize = self.initialize
|
self.handlers.initialize = self.initialize
|
||||||
@ -212,6 +215,9 @@ class IframeClient:
|
|||||||
msg = event.data
|
msg = event.data
|
||||||
data = msg.data
|
data = msg.data
|
||||||
if msg.encrypted:
|
if msg.encrypted:
|
||||||
|
if not self.gcm_from_parent:
|
||||||
|
print(f'the iframe {self.name}-{self.instance_num} got an encrypted message from its parent without being initialized')
|
||||||
|
return
|
||||||
# We cannot use self.encrypted_communications as the 'display'
|
# We cannot use self.encrypted_communications as the 'display'
|
||||||
# message has to be unencrypted as it transports Blob objects
|
# message has to be unencrypted as it transports Blob objects
|
||||||
try:
|
try:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user