Details
-
Bug
-
Resolution: Unresolved
-
Medium
-
None
-
5.8.2, 5.8.14, 5.9.6
-
4
-
Severity 2 - Major
-
2
-
Description
When you have a non-migrated macro definition of a contentbylabel parsed to a MacroDefinition object and then call XhtmlContent.convertMacroDefinitionToStorage the returned XHTML is broken.
In our case we get the page content in the transformer chain "storage to editor" and have to convert the macro body of our own macro back to Xhtml so it can be processed by later parts of the chain.
When the editor content then is saved the broken macro definition is then stored to the page and when you return to viewpage.action, the macro can't be rendered anymore.
You can easily construct the case with some code (have a debugger in the transformation chain to try it out). The MacroDefinition object is what I get from Confluence within a MacroDefinitionReplacer:
MacroDefinition contentByLabel = new MacroDefinition(new MacroDefinitionBuilder().withName("contentbylabel").withParameter("label", "some").withTypedParameter("label", "some").withParameter("spaces", "test").withTypedParameter("spaces", new SpaceResourceIdentifier("test")).withStorageVersion("2").withSchemaVersion(1)); String xhtmlString = xhtmlContent.convertMacroDefinitionToStorage(contentByLabel, new DefaultConversionContext(context.getEntity().toPageContext()));
The StorageMacroV2Marshaller messes up the representation of the space resource identifier. That's what it looks like:
<ac:structured-macro ac:name="contentbylabel" ac:schema-version="2" ac:macro-id="06af8213-3f7c-4877-b493-c521616fad10"><ac:parameter ac:name="label">some</ac:parameter><ac:parameter ac:name="spaces">com.atlassian.confluence.content.render.xhtml.model.resource.identifiers.SpaceResourceIdentifier@364492</ac:parameter><ac:parameter ac:name="cql">label = "some" and space = "test"</ac:parameter></ac:structured-macro>