From 0df29024da830c1004850e265609b8f0b6ae8273 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Mon, 18 Mar 2024 12:46:45 +0000 Subject: [PATCH] fix(x/upgrade): Stop treating inline JSON as a URL (backport #19706) (#19767) Co-authored-by: Richard Gibson Co-authored-by: marbar3778 --- x/upgrade/CHANGELOG.md | 4 ++++ x/upgrade/plan/info.go | 2 +- x/upgrade/plan/info_test.go | 6 ++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/x/upgrade/CHANGELOG.md b/x/upgrade/CHANGELOG.md index 8b652c3a0da2..83049232eb48 100644 --- a/x/upgrade/CHANGELOG.md +++ b/x/upgrade/CHANGELOG.md @@ -25,6 +25,10 @@ Ref: https://keepachangelog.com/en/1.0.0/ ## [Unreleased] +### Bug Fixes + +* [#19706](https://github.com/cosmos/cosmos-sdk/pull/19706) Stop treating inline JSON as a URL. + ## [v0.1.1](https://github.com/cosmos/cosmos-sdk/releases/tag/x/upgrade/v0.1.1) - 2023-12-11 ### Improvements diff --git a/x/upgrade/plan/info.go b/x/upgrade/plan/info.go index 545991c71b94..5ad692d3b18e 100644 --- a/x/upgrade/plan/info.go +++ b/x/upgrade/plan/info.go @@ -54,7 +54,7 @@ func ParseInfo(infoStr string, opts ...ParseOption) (*Info, error) { } // If it's a url, download it and treat the result as the real info. - if _, err := neturl.Parse(infoStr); err == nil { + if _, err := neturl.ParseRequestURI(infoStr); err == nil { if err := ValidateURL(infoStr, parseConfig.EnforceChecksum); err != nil { return nil, err } diff --git a/x/upgrade/plan/info_test.go b/x/upgrade/plan/info_test.go index b9b89e369ec3..48432935dbe2 100644 --- a/x/upgrade/plan/info_test.go +++ b/x/upgrade/plan/info_test.go @@ -74,6 +74,12 @@ func (s *InfoTestSuite) TestParseInfo() { expectedInfo: nil, expectedInError: []string{"plan info must not be blank"}, }, + { + name: "empty JSON", + infoStrMaker: makeInfoStrFuncString("{}"), + expectedInfo: &Info{}, + expectedInError: nil, + }, { name: "json binaries is wrong data type", infoStrMaker: makeInfoStrFuncString(binariesWrongJSON),