prevent <?xml verion> being output during encryption

This commit is contained in:
andrew.smith@miracl.com
2016-10-31 17:00:08 +00:00
parent 4c0831706e
commit 1720c7896d
2 changed files with 12 additions and 1 deletions

View File

@@ -279,5 +279,8 @@ func Encrypt(publicKey, doc []byte, opts EncryptOptions) ([]byte, error) {
}
encDataNode = nil // the template is inserted in the doc, so we don't own it
return dumpDoc(parsedDoc), nil
rootNode := C.xmlDocGetRootElement(parsedDoc)
buf := dumpNode(rootNode)
return buf, nil
}

View File

@@ -108,3 +108,11 @@ func dumpDoc(doc *C.xmlDoc) []byte {
return C.GoBytes(unsafe.Pointer(buffer), bufferSize)
}
func dumpNode(node *C.xmlNode) []byte {
buffer := C.xmlBufferCreate()
defer C.xmlBufferFree(buffer)
bufferSize := C.xmlNodeDump(buffer, nil, node, 0, 0)
return C.GoBytes(unsafe.Pointer(buffer.content), bufferSize)
}