aboutsummaryrefslogtreecommitdiffstats
path: root/background_scripts
diff options
context:
space:
mode:
authorStephen Blott2017-08-15 13:45:09 +0100
committerStephen Blott2017-08-15 13:45:09 +0100
commite0bbc1370abe6d27b78745ce87983055ba1bfdc3 (patch)
treeb236cf2d324ab72e3263710830eae288bbcc7150 /background_scripts
parent441b5266fcb6c8cdf57d4228a8f4c5a4deccc4c3 (diff)
downloadvimium-e0bbc1370abe6d27b78745ce87983055ba1bfdc3.tar.bz2
Fix search completion (Firefox).
The problem is that Firefox balks at function properties within the response sent via `postMessage` (whereas Chrome does not). A concise and safe way to sanitize the response is to convert it to JSON and back. Fixes #2576.
Diffstat (limited to 'background_scripts')
-rw-r--r--background_scripts/main.coffee4
1 files changed, 4 insertions, 0 deletions
diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee
index 6c9fbc98..15292ab6 100644
--- a/background_scripts/main.coffee
+++ b/background_scripts/main.coffee
@@ -50,6 +50,10 @@ completers =
completionHandlers =
filter: (completer, request, port) ->
completer.filter request, (response) ->
+ # NOTE(smblott): response contains `relevancyFunction` (function) properties which cause postMessage,
+ # below, to fail in Firefox. See #2576. We cannot simply delete these methods, as they're needed
+ # elsewhere. Converting the response to JSON and back is a quick and easy way to sanitize the object.
+ response = JSON.parse JSON.stringify response
# We use try here because this may fail if the sender has already navigated away from the original page.
# This can happen, for example, when posting completion suggestions from the SearchEngineCompleter
# (which is done asynchronously).