mirror of
https://github.com/httprunner/httprunner.git
synced 2026-07-12 16:01:27 +08:00
Merge pull request #1323 from bbx-winner/fix-escape-html
bugfix: avoid to escape html; empty base_url
This commit is contained in:
@@ -1,5 +1,9 @@
|
|||||||
# Release History
|
# 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)
|
## v4.1.0 (2022-05-29)
|
||||||
|
|
||||||
- feat: add `wiki` sub-command to open httprunner website
|
- feat: add `wiki` sub-command to open httprunner website
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"project_name": "demo-empty-project",
|
"project_name": "demo-empty-project",
|
||||||
"create_time": "2022-05-31T15:05:51.196187+08:00",
|
"create_time": "2022-05-31T15:05:51.196187+08:00",
|
||||||
"hrp_version": "v4.1.0"
|
"hrp_version": "v4.1.1"
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"project_name": "demo-with-go-plugin",
|
"project_name": "demo-with-go-plugin",
|
||||||
"create_time": "2022-05-31T15:05:49.894029+08:00",
|
"create_time": "2022-05-31T15:05:49.894029+08:00",
|
||||||
"hrp_version": "v4.1.0"
|
"hrp_version": "v4.1.1"
|
||||||
}
|
}
|
||||||
@@ -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 logging
|
||||||
import time
|
import time
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"project_name": "demo-with-py-plugin",
|
"project_name": "demo-with-py-plugin",
|
||||||
"create_time": "2022-05-31T15:05:50.036068+08:00",
|
"create_time": "2022-05-31T15:05:50.036068+08:00",
|
||||||
"hrp_version": "v4.1.0"
|
"hrp_version": "v4.1.1"
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"project_name": "demo-without-plugin",
|
"project_name": "demo-without-plugin",
|
||||||
"create_time": "2022-05-31T15:05:51.066376+08:00",
|
"create_time": "2022-05-31T15:05:51.066376+08:00",
|
||||||
"hrp_version": "v4.1.0"
|
"hrp_version": "v4.1.1"
|
||||||
}
|
}
|
||||||
@@ -28,8 +28,19 @@ func Dump2JSON(data interface{}, path string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
log.Info().Str("path", path).Msg("dump data to json")
|
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 {
|
if err != nil {
|
||||||
log.Error().Err(err).Msg("dump json path failed")
|
log.Error().Err(err).Msg("dump json path failed")
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -587,11 +587,11 @@ func (s *stepFromHAR) makeRequestBody(entry *Entry) error {
|
|||||||
s.Request.Body = body
|
s.Request.Body = body
|
||||||
} else if strings.HasPrefix(mimeType, "application/x-www-form-urlencoded") {
|
} else if strings.HasPrefix(mimeType, "application/x-www-form-urlencoded") {
|
||||||
// post form
|
// post form
|
||||||
var paramsList []string
|
paramsMap := make(map[string]string)
|
||||||
for _, param := range entry.Request.PostData.Params {
|
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") {
|
} else if strings.HasPrefix(mimeType, "text/plain") {
|
||||||
// post raw data
|
// post raw data
|
||||||
s.Request.Body = entry.Request.PostData.Text
|
s.Request.Body = entry.Request.PostData.Text
|
||||||
|
|||||||
@@ -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) {
|
if !assert.Equal(t, map[string]interface{}{"foo1": "HDnY8", "foo2": 12.3}, tCase.TestSteps[1].Request.Body) {
|
||||||
t.Fatal()
|
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()
|
t.Fatal()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -264,7 +264,7 @@ func TestMakeRequestDataParams(t *testing.T) {
|
|||||||
t.Fatal()
|
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()
|
t.Fatal()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,5 +12,6 @@ var (
|
|||||||
MarshalIndent = json.MarshalIndent
|
MarshalIndent = json.MarshalIndent
|
||||||
Unmarshal = json.Unmarshal
|
Unmarshal = json.Unmarshal
|
||||||
NewDecoder = json.NewDecoder
|
NewDecoder = json.NewDecoder
|
||||||
|
NewEncoder = json.NewEncoder
|
||||||
Get = json.Get
|
Get = json.Get
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -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 logging
|
||||||
import time
|
import time
|
||||||
|
|||||||
@@ -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
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@@ -12,5 +12,5 @@ func main() {
|
|||||||
fungo.Register("SetupHookExample", SetupHookExample)
|
fungo.Register("SetupHookExample", SetupHookExample)
|
||||||
fungo.Register("TeardownHookExample", TeardownHookExample)
|
fungo.Register("TeardownHookExample", TeardownHookExample)
|
||||||
fungo.Register("GetUserAgent", GetUserAgent)
|
fungo.Register("GetUserAgent", GetUserAgent)
|
||||||
fungo.Serve()
|
fungo.Serve()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
v4.1.0
|
v4.1.1
|
||||||
@@ -7,4 +7,4 @@ import (
|
|||||||
//go:embed VERSION
|
//go:embed VERSION
|
||||||
var VERSION string
|
var VERSION string
|
||||||
|
|
||||||
const HttpRunnerMinVersion = "v4.0.0-beta"
|
const HttpRunnerMinVersion = "v4.1.0"
|
||||||
|
|||||||
@@ -145,7 +145,10 @@ func (r *requestBuilder) prepareUrlParams(stepVariables map[string]interface{})
|
|||||||
log.Error().Err(err).Msg("parse request url failed")
|
log.Error().Err(err).Msg("parse request url failed")
|
||||||
return err
|
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))
|
rawUrl := buildURL(baseURL, convertString(requestUrl))
|
||||||
|
|
||||||
// prepare request params
|
// prepare request params
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
__version__ = "v4.1.0"
|
__version__ = "v4.1.1"
|
||||||
__description__ = "One-stop solution for HTTP(S) testing."
|
__description__ = "One-stop solution for HTTP(S) testing."
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "httprunner"
|
name = "httprunner"
|
||||||
version = "v4.1.0"
|
version = "v4.1.1"
|
||||||
description = "One-stop solution for HTTP(S) testing."
|
description = "One-stop solution for HTTP(S) testing."
|
||||||
license = "Apache-2.0"
|
license = "Apache-2.0"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
|
|||||||
Reference in New Issue
Block a user