diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index fca6ed2d..ae07bc3c 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,5 +1,9 @@ # Release History +## v4.1.1 (2022-05-31) +- fix: failed to build debugtalk.go without go.mod +- fix: avoid to escape from html special characters like '&' + ## v4.1.0 (2022-05-29) - feat: add `wiki` sub-command to open httprunner website diff --git a/examples/demo-empty-project/proj.json b/examples/demo-empty-project/proj.json index 4ce79550..5d124adb 100644 --- a/examples/demo-empty-project/proj.json +++ b/examples/demo-empty-project/proj.json @@ -1,5 +1,5 @@ { "project_name": "demo-empty-project", "create_time": "2022-05-31T15:05:51.196187+08:00", - "hrp_version": "v4.1.0" + "hrp_version": "v4.1.1" } \ No newline at end of file diff --git a/examples/demo-with-go-plugin/proj.json b/examples/demo-with-go-plugin/proj.json index 1dc616b6..be9dfdaf 100644 --- a/examples/demo-with-go-plugin/proj.json +++ b/examples/demo-with-go-plugin/proj.json @@ -1,5 +1,5 @@ { "project_name": "demo-with-go-plugin", "create_time": "2022-05-31T15:05:49.894029+08:00", - "hrp_version": "v4.1.0" + "hrp_version": "v4.1.1" } \ No newline at end of file diff --git a/examples/demo-with-py-plugin/.debugtalk_gen.py b/examples/demo-with-py-plugin/.debugtalk_gen.py index 1bc989f2..d3b72a66 100644 --- a/examples/demo-with-py-plugin/.debugtalk_gen.py +++ b/examples/demo-with-py-plugin/.debugtalk_gen.py @@ -1,4 +1,4 @@ -# NOTE: Generated By hrp v4.1.0, DO NOT EDIT! +# NOTE: Generated By hrp v4.1.1, DO NOT EDIT! import logging import time diff --git a/examples/demo-with-py-plugin/proj.json b/examples/demo-with-py-plugin/proj.json index c854eeb0..ccf2b5d5 100644 --- a/examples/demo-with-py-plugin/proj.json +++ b/examples/demo-with-py-plugin/proj.json @@ -1,5 +1,5 @@ { "project_name": "demo-with-py-plugin", "create_time": "2022-05-31T15:05:50.036068+08:00", - "hrp_version": "v4.1.0" + "hrp_version": "v4.1.1" } \ No newline at end of file diff --git a/examples/demo-without-plugin/proj.json b/examples/demo-without-plugin/proj.json index afe69717..7c95fdb6 100644 --- a/examples/demo-without-plugin/proj.json +++ b/examples/demo-without-plugin/proj.json @@ -1,5 +1,5 @@ { "project_name": "demo-without-plugin", "create_time": "2022-05-31T15:05:51.066376+08:00", - "hrp_version": "v4.1.0" + "hrp_version": "v4.1.1" } \ No newline at end of file diff --git a/hrp/internal/builtin/utils.go b/hrp/internal/builtin/utils.go index 09176168..8f3ca391 100644 --- a/hrp/internal/builtin/utils.go +++ b/hrp/internal/builtin/utils.go @@ -28,8 +28,19 @@ func Dump2JSON(data interface{}, path string) error { return err } log.Info().Str("path", path).Msg("dump data to json") - file, _ := json.MarshalIndent(data, "", " ") - err = os.WriteFile(path, file, 0o644) + + // init json encoder + buffer := new(bytes.Buffer) + encoder := json.NewEncoder(buffer) + encoder.SetEscapeHTML(false) + encoder.SetIndent("", " ") + + err = encoder.Encode(data) + if err != nil { + return err + } + + err = os.WriteFile(path, buffer.Bytes(), 0o644) if err != nil { log.Error().Err(err).Msg("dump json path failed") return err diff --git a/hrp/internal/convert/converter_har.go b/hrp/internal/convert/converter_har.go index d35a9031..6ee9c156 100644 --- a/hrp/internal/convert/converter_har.go +++ b/hrp/internal/convert/converter_har.go @@ -587,11 +587,11 @@ func (s *stepFromHAR) makeRequestBody(entry *Entry) error { s.Request.Body = body } else if strings.HasPrefix(mimeType, "application/x-www-form-urlencoded") { // post form - var paramsList []string + paramsMap := make(map[string]string) for _, param := range entry.Request.PostData.Params { - paramsList = append(paramsList, fmt.Sprintf("%s=%s", param.Name, param.Value)) + paramsMap[param.Name] = param.Value } - s.Request.Body = strings.Join(paramsList, "&") + s.Request.Body = paramsMap } else if strings.HasPrefix(mimeType, "text/plain") { // post raw data s.Request.Body = entry.Request.PostData.Text diff --git a/hrp/internal/convert/converter_har_test.go b/hrp/internal/convert/converter_har_test.go index 0d4daa11..af94c98c 100644 --- a/hrp/internal/convert/converter_har_test.go +++ b/hrp/internal/convert/converter_har_test.go @@ -118,7 +118,7 @@ func TestMakeTestCaseFromHAR(t *testing.T) { if !assert.Equal(t, map[string]interface{}{"foo1": "HDnY8", "foo2": 12.3}, tCase.TestSteps[1].Request.Body) { t.Fatal() } - if !assert.Equal(t, "foo1=HDnY8&foo2=12.3", tCase.TestSteps[2].Request.Body) { + if !assert.Equal(t, map[string]string{"foo1": "HDnY8", "foo2": "12.3"}, tCase.TestSteps[2].Request.Body) { t.Fatal() } @@ -264,7 +264,7 @@ func TestMakeRequestDataParams(t *testing.T) { t.Fatal() } - if !assert.Equal(t, "a=1&b=2", step.Request.Body) { + if !assert.Equal(t, map[string]string{"a": "1", "b": "2"}, step.Request.Body) { t.Fatal() } } diff --git a/hrp/internal/json/json.go b/hrp/internal/json/json.go index 859d1e28..640946e5 100644 --- a/hrp/internal/json/json.go +++ b/hrp/internal/json/json.go @@ -12,5 +12,6 @@ var ( MarshalIndent = json.MarshalIndent Unmarshal = json.Unmarshal NewDecoder = json.NewDecoder + NewEncoder = json.NewEncoder Get = json.Get ) diff --git a/hrp/internal/scaffold/templates/plugin/.debugtalk_gen.py b/hrp/internal/scaffold/templates/plugin/.debugtalk_gen.py index 1bc989f2..d3b72a66 100644 --- a/hrp/internal/scaffold/templates/plugin/.debugtalk_gen.py +++ b/hrp/internal/scaffold/templates/plugin/.debugtalk_gen.py @@ -1,4 +1,4 @@ -# NOTE: Generated By hrp v4.1.0, DO NOT EDIT! +# NOTE: Generated By hrp v4.1.1, DO NOT EDIT! import logging import time diff --git a/hrp/internal/scaffold/templates/plugin/debugtalk_gen.go b/hrp/internal/scaffold/templates/plugin/debugtalk_gen.go index ad875187..1def5aa4 100644 --- a/hrp/internal/scaffold/templates/plugin/debugtalk_gen.go +++ b/hrp/internal/scaffold/templates/plugin/debugtalk_gen.go @@ -1,4 +1,4 @@ -// NOTE: Generated By hrp v4.1.0, DO NOT EDIT! +// NOTE: Generated By hrp v4.1.1, DO NOT EDIT! package main import ( @@ -12,5 +12,5 @@ func main() { fungo.Register("SetupHookExample", SetupHookExample) fungo.Register("TeardownHookExample", TeardownHookExample) fungo.Register("GetUserAgent", GetUserAgent) - fungo.Serve() + fungo.Serve() } diff --git a/hrp/internal/version/VERSION b/hrp/internal/version/VERSION index 5469c48c..4b23c7e2 100644 --- a/hrp/internal/version/VERSION +++ b/hrp/internal/version/VERSION @@ -1 +1 @@ -v4.1.0 \ No newline at end of file +v4.1.1 \ No newline at end of file diff --git a/hrp/internal/version/init.go b/hrp/internal/version/init.go index 65b56ebc..836ffca7 100644 --- a/hrp/internal/version/init.go +++ b/hrp/internal/version/init.go @@ -7,4 +7,4 @@ import ( //go:embed VERSION var VERSION string -const HttpRunnerMinVersion = "v4.0.0-beta" +const HttpRunnerMinVersion = "v4.1.0" diff --git a/hrp/step_request.go b/hrp/step_request.go index 39e15d74..28b174ce 100644 --- a/hrp/step_request.go +++ b/hrp/step_request.go @@ -145,7 +145,10 @@ func (r *requestBuilder) prepareUrlParams(stepVariables map[string]interface{}) log.Error().Err(err).Msg("parse request url failed") return err } - baseURL := stepVariables["base_url"].(string) + var baseURL string + if stepVariables["base_url"] != nil { + baseURL = stepVariables["base_url"].(string) + } rawUrl := buildURL(baseURL, convertString(requestUrl)) // prepare request params diff --git a/httprunner/__init__.py b/httprunner/__init__.py index 562a9028..245ddbf5 100644 --- a/httprunner/__init__.py +++ b/httprunner/__init__.py @@ -1,4 +1,4 @@ -__version__ = "v4.1.0" +__version__ = "v4.1.1" __description__ = "One-stop solution for HTTP(S) testing." diff --git a/pyproject.toml b/pyproject.toml index 9f56803d..b3f49e14 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "httprunner" -version = "v4.1.0" +version = "v4.1.1" description = "One-stop solution for HTTP(S) testing." license = "Apache-2.0" readme = "README.md"