From 9f91a3fc41a9ad97e1e92337819145e604ac4f34 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Sun, 17 Apr 2016 08:46:57 +0100 Subject: For javascript URLs, do not match javascript content. We only match the text "javascript:...". The affects only the bookmark completer. --- background_scripts/completion.coffee | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/background_scripts/completion.coffee b/background_scripts/completion.coffee index 9980fb10..db69f15c 100644 --- a/background_scripts/completion.coffee +++ b/background_scripts/completion.coffee @@ -66,15 +66,11 @@ class Suggestion
""" - # Simplify "javascript:" URLs; show them as "javascript:..."; see #961. - simplifyJavascriptUrls: (url) -> - if Utils.hasJavascriptPrefix(url) then "javascript:..." else url - # Use neat trick to snatch a domain (http://stackoverflow.com/a/8498668). getUrlRoot: (url) -> a = document.createElement 'a' @@ -150,6 +146,8 @@ class Suggestion # Simplify a suggestion's URL (by removing those parts which aren't useful for display or comparison). shortenUrl: () -> + # If we already have display URL, then use it. + @shortUrl ?= @displayUrl return @shortUrl if @shortUrl? # We get easier-to-read shortened URLs if we URI-decode them. url = (Utils.decodeURIByParts(@url) || @url).toLowerCase() @@ -208,7 +206,10 @@ class BookmarkCompleter if @currentSearch.queryTerms.length > 0 @bookmarks.filter (bookmark) => suggestionTitle = if usePathAndTitle then bookmark.pathAndTitle else bookmark.title - RankingUtils.matches(@currentSearch.queryTerms, bookmark.url, suggestionTitle) + bookmark.hasJavascriptPrefix ?= Utils.hasJavascriptPrefix bookmark.url + bookmark.displayUrl ?= "javascript:..." if bookmark.hasJavascriptPrefix + suggestionUrl = bookmark.displayUrl ? bookmark.url + RankingUtils.matches(@currentSearch.queryTerms, suggestionUrl, suggestionTitle) else [] suggestions = results.map (bookmark) => @@ -216,6 +217,7 @@ class BookmarkCompleter queryTerms: @currentSearch.queryTerms type: "bookmark" url: bookmark.url + displayUrl: bookmark.displayUrl title: if usePathAndTitle then bookmark.pathAndTitle else bookmark.title relevancyFunction: @computeRelevancy onComplete = @currentSearch.onComplete @@ -252,7 +254,7 @@ class BookmarkCompleter bookmark.children.forEach((child) => @traverseBookmarksRecursive child, results, bookmark) if bookmark.children computeRelevancy: (suggestion) -> - RankingUtils.wordRelevancy(suggestion.queryTerms, suggestion.url, suggestion.title) + RankingUtils.wordRelevancy(suggestion.queryTerms, suggestion.displayUrl ? suggestion.url, suggestion.title) class HistoryCompleter filter: ({ queryTerms, seenTabToOpenCompletionList }, onComplete) -> -- cgit v1.2.3