Xml-escape mimetype in http-upload (thx Zash).

v0.1
Martin Dosch 3 years ago
parent a52a15e9d1
commit 063db2769f

@ -118,6 +118,8 @@ func httpUpload(client *xmpp.Client, jserver string, filePath string) string {
// Get mime type
mimeType := mimetype.Detect(buffer).String()
var mimeTypeEscaped bytes.Buffer
xml.Escape(&mimeTypeEscaped, []byte(mimeType))
// Get file name
fileName := filepath.Base(filePath)
@ -199,7 +201,7 @@ func httpUpload(client *xmpp.Client, jserver string, filePath string) string {
_, err = client.RawInformation(client.JID(), uploadComponent, id, "get",
"<request xmlns='urn:xmpp:http:upload:0' filename='"+
fileNameEscaped.String()+"' size='"+strconv.FormatInt(fileSize, 10)+
"' content-type='"+mimeType+"' />")
"' content-type='"+mimeTypeEscaped.String()+"' />")
if err != nil {
log.Fatal(err)
}
@ -219,7 +221,7 @@ func httpUpload(client *xmpp.Client, jserver string, filePath string) string {
if err != nil {
log.Fatal(err)
}
req.Header.Set("Content-Type", mimeType)
req.Header.Set("Content-Type", mimeTypeEscaped.String())
for _, h := range iqHttpUploadSlotXML.Put.Headers {
switch h.Name {
case "Authorization", "Cookie", "Expires":

Loading…
Cancel
Save