Plugins: Fix colon in CallResource URL returning an error when creating plugin resource request (#79746)
* Plugin: handle colon character in path url.Parse() does not handle the given input correctly when the input contains a colon character. The user will see the following error message when trying to use remote cluster in Elasticsearch: ``` level=warn msg="Failed for create plugin resource request" error="parse \"foo-*,*:foo-*/_mapping\": first path segment in URL cannot contain colon" traceID= ``` As far as I can tell, we only want to set the path here + rawquery so avoid url.Parse() altogether. * Add more tests --------- Co-authored-by: Giuseppe Guerra <giuseppe@guerra.in>
This commit is contained in:
co-authored by
Giuseppe Guerra
parent
34eb50dab3
commit
6f245121d0
@@ -90,14 +90,11 @@ func (hs *HTTPServer) callPluginResourceWithDataSource(c *contextmodel.ReqContex
|
||||
func (hs *HTTPServer) pluginResourceRequest(c *contextmodel.ReqContext) (*http.Request, error) {
|
||||
clonedReq := c.Req.Clone(c.Req.Context())
|
||||
rawURL := web.Params(c.Req)["*"]
|
||||
if clonedReq.URL.RawQuery != "" {
|
||||
rawURL += "?" + clonedReq.URL.RawQuery
|
||||
|
||||
clonedReq.URL = &url.URL{
|
||||
Path: rawURL,
|
||||
RawQuery: clonedReq.URL.RawQuery,
|
||||
}
|
||||
urlPath, err := url.Parse(rawURL)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
clonedReq.URL = urlPath
|
||||
|
||||
return clonedReq, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user