Kaydet (Commit) 99c59c59 authored tarafından Damjan Jovanovic's avatar Damjan Jovanovic Kaydeden (comit) Michael Stahl

Set up our own libxslt security context in xmlhelp, as per #i117643.

Patch by: me

(cherry picked from commit ae1f34be)

Change-Id: I0e5277b17243f6b8f5f4303206cf446b10dd0aef
Reviewed-on: https://gerrit.libreoffice.org/61597Reviewed-by: 's avatarMichael Stahl <Michael.Stahl@cib.de>
Tested-by: 's avatarMichael Stahl <Michael.Stahl@cib.de>
üst de29c77c
......@@ -31,6 +31,7 @@
#include <libxslt/xslt.h>
#include <libxslt/transform.h>
#include <libxslt/xsltutils.h>
#include <libxslt/security.h>
#include "db.hxx"
#include <com/sun/star/io/XActiveDataSink.hpp>
#include <com/sun/star/io/XInputStream.hpp>
......@@ -847,14 +848,29 @@ InputStreamTransformer::InputStreamTransformer( URLParameter* urlParam,
xmlDocPtr doc = xmlParseFile("vnd.sun.star.zip:/");
xmlDocPtr res = xsltApplyStylesheet(cur, doc, parameter);
if (res)
xmlDocPtr res = nullptr;
xsltTransformContextPtr transformContext = xsltNewTransformContext(cur, doc);
if (transformContext)
{
xmlChar *doc_txt_ptr=nullptr;
int doc_txt_len;
xsltSaveResultToString(&doc_txt_ptr, &doc_txt_len, res, cur);
addToBuffer(reinterpret_cast<char*>(doc_txt_ptr), doc_txt_len);
xmlFree(doc_txt_ptr);
xsltSecurityPrefsPtr securityPrefs = xsltNewSecurityPrefs();
if (securityPrefs)
{
xsltSetSecurityPrefs(securityPrefs, XSLT_SECPREF_READ_FILE, xsltSecurityAllow);
if (xsltSetCtxtSecurityPrefs(securityPrefs, transformContext) == 0)
{
res = xsltApplyStylesheetUser(cur, doc, parameter, nullptr, nullptr, transformContext);
if (res)
{
xmlChar *doc_txt_ptr=nullptr;
int doc_txt_len;
xsltSaveResultToString(&doc_txt_ptr, &doc_txt_len, res, cur);
addToBuffer(reinterpret_cast<char*>(doc_txt_ptr), doc_txt_len);
xmlFree(doc_txt_ptr);
}
}
xsltFreeSecurityPrefs(securityPrefs);
}
xsltFreeTransformContext(transformContext);
}
xmlPopInputCallbacks(); //filePatch
xmlPopInputCallbacks(); //helpPatch
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment