|
@@ -7,6 +7,7 @@ import (
|
|
|
"encoding/json"
|
|
"encoding/json"
|
|
|
"errors"
|
|
"errors"
|
|
|
"github.com/google/uuid"
|
|
"github.com/google/uuid"
|
|
|
|
|
+ "regexp"
|
|
|
|
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
|
)
|
|
)
|
|
@@ -26,8 +27,14 @@ func NewTranscoderCallbackLogic(ctx context.Context, svcCtx *svc.ServiceContext)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func (l *TranscoderCallbackLogic) TranscoderCallback(req *types.CallbackRequest) (resp *types.CallbackResponse, err error) {
|
|
func (l *TranscoderCallbackLogic) TranscoderCallback(req *types.CallbackRequest) (resp *types.CallbackResponse, err error) {
|
|
|
- if req.Path == "" {
|
|
|
|
|
- err = errors.New("path is empty")
|
|
|
|
|
|
|
+ if req.Path == "" || req.CallbackUrl == "" {
|
|
|
|
|
+ err = errors.New("path or callback_url is empty")
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ //校验req.Path是否符合url的正则格式
|
|
|
|
|
+ var urlRegexp = regexp.MustCompile(`^(?:(http|https|ftp):\/\/)?((|[\w-]+\.)+[a-z0-9]+)(?:(\/[^/?#]+)*)?(\?[^#]+)?(#.+)?$`)
|
|
|
|
|
+ if !urlRegexp.MatchString(req.Path) || urlRegexp.MatchString(req.CallbackUrl) {
|
|
|
|
|
+ err = errors.New("path or callback_url is not url")
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
bts, err := json.Marshal(req)
|
|
bts, err := json.Marshal(req)
|