fix webmention validation content-type with charset would fail
parent
56b84125c4
commit
d2cffd68b0
|
@ -8,7 +8,6 @@ import (
|
|||
"brainbaking.com/go-jamming/rest"
|
||||
"encoding/xml"
|
||||
"fmt"
|
||||
"github.com/rs/zerolog/log"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
)
|
||||
|
@ -94,7 +93,8 @@ func pingbackError(w http.ResponseWriter, err error) {
|
|||
</value>
|
||||
</fault>
|
||||
</methodResponse>`
|
||||
log.Error().Err(err).Msg("Pingback receive went wrong")
|
||||
// No longer interested in pingback errors, these are 99.9% badly formatted spam that clog up syslog
|
||||
// log.Error().Err(err).Msg("Pingback receive went wrong")
|
||||
w.WriteHeader(200)
|
||||
w.Write([]byte(xml))
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ func isValidTargetUrl(url string, httpClient rest.Client) bool {
|
|||
}
|
||||
|
||||
func validate(r rest.HttpReq, h rest.HttpHeader, conf *common.Config) bool {
|
||||
return h.Get("Content-Type") == "application/x-www-form-urlencoded" &&
|
||||
return strings.HasPrefix(h.Get("Content-Type"), "application/x-www-form-urlencoded") &&
|
||||
isValidUrl(r.FormValue("source")) &&
|
||||
isValidUrl(r.FormValue("target")) &&
|
||||
r.FormValue("source") != r.FormValue("target") &&
|
||||
|
|
|
@ -56,6 +56,13 @@ func TestValidate(t *testing.T) {
|
|||
contentType string
|
||||
expected bool
|
||||
}{
|
||||
{
|
||||
"is valid if encoded as form including the charset",
|
||||
"https://brainbaking.com/bla1",
|
||||
"https://jefklakscodex.com/bla",
|
||||
"application/x-www-form-urlencoded; charset=utf-8",
|
||||
true,
|
||||
},
|
||||
{
|
||||
"is valid if source and target https urls",
|
||||
"http://brainbaking.com/bla1",
|
||||
|
|
Loading…
Reference in New Issue