How to commit <style> tag into Alfresco node?

I am trying to write a HTML content into Alfresco node using this service https://docs.alfresco.com/5.2/references/dev-services-content.html but this service cut out "style", "script" and some other tags!!! how to prevent it and write "style" tag in output stream?

protected void exportReportVHTML(NodeRef reportNodeRef,
                            String outputFormat, String report) throws JRException, IOException {
    ContentWriter contentWriter = alfrescoServices.getContentServiceDefault().getWriter(reportNodeRef,
            ContentModel.PROP_CONTENT, true);
    OutputStream reportOS = contentWriter.getContentOutputStream();

    contentWriter.setMimetype(alfrescoServices.getMimetypeService().getMimetype("html"));
    try {
        reportOS.write(report.getBytes("UTF-8"));
    } catch (Exception jrex) {
        jrex.printStackTrace();
        jrex.printStackTrace(new PrintWriter(reportOS));
        propertyHelper.setNodeProp(reportNodeRef, ContentModel.PROP_DESCRIPTION, jrex.getMessage());
        throw jrex;
    } finally {
        reportOS.close();
    }
}

Upvotes: 2

Views: 84

Answers (1)

Curtis
Curtis

Reputation: 558

The contentwriter shouldn't be stripping out tags.

If you download the html from the node, the tags should be retained. Perhaps they are being removed in a "view in browser" or editor view (as tags deemed unsafe are typically removed).

See how to whitelist tags here

Upvotes: 2

Related Questions