prevent <?xml verion> being output during encryption
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user