From faed2ac132ec79e50015db6cabeb3c33c49836b6 Mon Sep 17 00:00:00 2001 From: "taylor.smock" Date: Tue, 8 Oct 2024 12:39:56 +0000 Subject: [PATCH] Fix #23956: JsonParsingException when the destination server returns 200 and a malformed document In this case, the destination server performed a redirect via javascript in the response. git-svn-id: https://josm.openstreetmap.de/svn/trunk@19235 0c6e7542-c601-0410-84e7-c038aed88b3b --- src/org/openstreetmap/josm/data/oauth/OAuthParameters.java | 6 ++++-- .../josm/gui/oauth/OAuthAuthorizationWizard.java | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/org/openstreetmap/josm/data/oauth/OAuthParameters.java b/src/org/openstreetmap/josm/data/oauth/OAuthParameters.java index e58d032421b..86a476057ef 100644 --- a/src/org/openstreetmap/josm/data/oauth/OAuthParameters.java +++ b/src/org/openstreetmap/josm/data/oauth/OAuthParameters.java @@ -9,6 +9,7 @@ import java.util.HashMap; import java.util.Map; +import jakarta.json.stream.JsonParsingException; import org.openstreetmap.josm.io.NetworkManager; import org.openstreetmap.josm.io.OsmApi; import org.openstreetmap.josm.io.auth.CredentialsAgentException; @@ -94,7 +95,7 @@ private static JsonObject getRFC8414Parameters(String apiUrl) { } } } - } catch (URISyntaxException | IOException e) { + } catch (JsonParsingException | URISyntaxException | IOException e) { throw new JosmRuntimeException(e); } finally { if (client != null) { @@ -157,7 +158,8 @@ private static OAuth20Parameters getDefaultOAuth20Parameters(String apiUrl) { } } } catch (JosmRuntimeException e) { - if (e.getCause() instanceof URISyntaxException || e.getCause() instanceof IOException) { + if (e.getCause() instanceof URISyntaxException || e.getCause() instanceof IOException + || e.getCause() instanceof JsonParsingException) { Logging.trace(e); } else { throw e; diff --git a/src/org/openstreetmap/josm/gui/oauth/OAuthAuthorizationWizard.java b/src/org/openstreetmap/josm/gui/oauth/OAuthAuthorizationWizard.java index aa1e37538ca..a4ff52d723e 100644 --- a/src/org/openstreetmap/josm/gui/oauth/OAuthAuthorizationWizard.java +++ b/src/org/openstreetmap/josm/gui/oauth/OAuthAuthorizationWizard.java @@ -175,7 +175,7 @@ protected JPanel buildHeaderInfoPanel() { // the authorisation procedure JMultilineLabel lbl = new JMultilineLabel(AuthorizationProcedure.FULLY_AUTOMATIC.getDescription()); lbl.setFont(lbl.getFont().deriveFont(Font.PLAIN)); - pnl.add(lbl, GBC.std()); + pnl.add(lbl, GBC.eol()); if (!Config.getUrls().getDefaultOsmApiUrl().equals(apiUrl)) { final HtmlPanel pnlWarning = new HtmlPanel();