Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
Handle utf8 encoding search results
Browse files Browse the repository at this point in the history
fix #11297

Auditors: @bsclifton, @bbondy

Test Plan:
1. Go to about:preferences#search and turn on
  `Autocomplete search term as you type`
2. Set search engine to Google (ISO-8859-1)
3. Type "功德" on URL input
4. There shouldn't be any jibberish results
5. Set search engine to Bing/DDG (UTF-8)
6. Type "功德" on URL input
7. There shouldn't be any jibberish results
  • Loading branch information
darkdh authored and bsclifton committed Feb 9, 2018
1 parent aa970e8 commit be4b830
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions app/common/lib/fetchSearchSuggestions.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@ const fetchSearchSuggestions = debounce((windowId, tabId, autocompleteURL, searc
return
}

const contentType = response['headers']['content-type']
if (contentType && contentType.search(/utf-8/i) !== -1) {
let utf8SearchResults = []
for (let i = 0; i < searchResults.length; ++i) {
utf8SearchResults.push(decodeURIComponent(escape(searchResults[i])))
}
const utf8Query = decodeURIComponent(escape(query))
searchResults = utf8SearchResults
query = utf8Query
}
// Once we have the online suggestions, append them to the others
appActions.searchSuggestionResultsAvailable(tabId, query, searchResults)
})
Expand Down

0 comments on commit be4b830

Please sign in to comment.