From c114473368cbd182a29484bddccd571f300d29c3 Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Mon, 8 Apr 2019 01:43:57 -0700 Subject: [PATCH] Fix UTF-8 encoding. --- .../thauvin/erik/mobibot/modules/GoogleSearch.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/main/java/net/thauvin/erik/mobibot/modules/GoogleSearch.java b/src/main/java/net/thauvin/erik/mobibot/modules/GoogleSearch.java index 48ab1b7..a05775f 100644 --- a/src/main/java/net/thauvin/erik/mobibot/modules/GoogleSearch.java +++ b/src/main/java/net/thauvin/erik/mobibot/modules/GoogleSearch.java @@ -52,13 +52,12 @@ import java.nio.charset.StandardCharsets; * @since 1.0 */ public final class GoogleSearch extends ThreadedModule { - /** - * The google command. - */ - public static final String GOOGLE_CMD = "google"; - // The Google API Key property. private static final String GOOGLE_API_KEY_PROP = "google-api-key"; + + // The Google command + private static final String GOOGLE_CMD = "google"; + // The Google Custom Search Engine ID property. private static final String GOOGLE_CSE_KEY_PROP = "google-cse-cx"; @@ -86,14 +85,14 @@ public final class GoogleSearch extends ThreadedModule { bot.send(sender, "The Google searching facility is disabled."); } } - + /** * Searches Google. */ @SuppressFBWarnings(value = {"URLCONNECTION_SSRF_FD", "REC_CATCH_EXCEPTION"}) void run(final Mobibot bot, final String sender, final String query) { try { - final String q = URLEncoder.encode(query, "UTF-8"); + final String q = URLEncoder.encode(query, StandardCharsets.UTF_8.toString()); final URL url = new URL("https://www.googleapis.com/customsearch/v1?key="