diff --git a/src/apps/webpositive/BrowserWindow.cpp b/src/apps/webpositive/BrowserWindow.cpp index 54a3354f3b..1775967357 100644 --- a/src/apps/webpositive/BrowserWindow.cpp +++ b/src/apps/webpositive/BrowserWindow.cpp @@ -2259,6 +2259,9 @@ BrowserWindow::_NewTabURL(bool isNewWindow) const BString BrowserWindow::_EncodeURIComponent(const BString& search) { + // We have to take care of some of the escaping before we hand over the + // search string to WebKit, if we want queries like "4+3" to not be + // searched as "4 3". const BString escCharList = " $&`:<>[]{}\"+#%@/;=?\\^|~\',"; BString result = search; char hexcode[4]; @@ -2287,15 +2290,10 @@ BrowserWindow::_VisitURL(const BString& url) void BrowserWindow::_VisitSearchEngine(const BString& search) { - // TODO: Google Code-In Task to make default search - // engine modifiable from Settings? :) - - BString engine = "http://www.google.com/search?q="; - engine += _EncodeURIComponent(search); - // We have to take care of some of the escaping before - // we hand over the string to WebKit, if we want queries - // like "4+3" to not be searched as "4 3". - + BString engine = ""; + engine.SetToFormat(fSearchPageURL, + _EncodeURIComponent(search).String()); + _VisitURL(engine); } @@ -2303,11 +2301,9 @@ BrowserWindow::_VisitSearchEngine(const BString& search) inline bool BrowserWindow::_IsValidDomainChar(char ch) { - // TODO: Currenlty, only a whitespace character - // breaks a domain name. It might be - // a good idea (or a bad one) to make - // character filtering based on the - // IDNA 2008 standard. + // TODO: Currenlty, only a whitespace character breaks a domain name. It + // might be a good idea (or a bad one) to make character filtering based on + // the IDNA 2008 standard. return ch != ' '; } diff --git a/src/apps/webpositive/SettingsKeys.cpp b/src/apps/webpositive/SettingsKeys.cpp index 7d106d1be5..c724682654 100644 --- a/src/apps/webpositive/SettingsKeys.cpp +++ b/src/apps/webpositive/SettingsKeys.cpp @@ -23,7 +23,7 @@ const char* kSettingsKeySearchPageURL = "search page url"; const char* kDefaultDownloadPath = "/boot/home/Desktop/"; const char* kDefaultStartPageURL = "file:///boot/home/config/settings/WebPositive/LoaderPages/Welcome"; -const char* kDefaultSearchPageURL = "http://www.google.com"; +const char* kDefaultSearchPageURL = "http://www.google.com/search?q=%s"; const char* kSettingsKeyUseProxy = "use http proxy"; const char* kSettingsKeyProxyAddress = "http proxy address"; diff --git a/src/apps/webpositive/SettingsWindow.cpp b/src/apps/webpositive/SettingsWindow.cpp index 93473dd51d..70bdf84cf7 100644 --- a/src/apps/webpositive/SettingsWindow.cpp +++ b/src/apps/webpositive/SettingsWindow.cpp @@ -245,8 +245,14 @@ SettingsWindow::_CreateGeneralPage(float spacing) new BMessage(MSG_SEARCH_PAGE_CHANGED)); fSearchPageControl->SetModificationMessage( new BMessage(MSG_SEARCH_PAGE_CHANGED)); - fSearchPageControl->SetText( - fSettings->GetValue(kSettingsKeySearchPageURL, kDefaultSearchPageURL)); + BString searchURL = fSettings->GetValue(kSettingsKeySearchPageURL, + kDefaultSearchPageURL); + if (searchURL == "http://www.google.com") { + // Migrate old settings files. + searchURL = kDefaultSearchPageURL; + fSettings->SetValue(kSettingsKeySearchPageURL, kDefaultSearchPageURL); + } + fSearchPageControl->SetText(searchURL); fDownloadFolderControl = new BTextControl("download folder", B_TRANSLATE("Download folder:"), "",