Uploaded image for project: 'Confluence Data Center'
  1. Confluence Data Center
  2. CONFSERVER-52591

Automatic merge corrupts macros when XhtmlContent.updateMacroDefinitions is used

      Summary

      Automatic merge corrupts macros when XhtmlContent.updateMacroDefinitions is used

      Steps to Reproduce

      1. Install macro with an editorToStorage transformer module that uses updateMacroDefinitions, but makes no changes (code below)
      2. Disable collaborative editing
      3. Open a page for editing with two different users; admin and guest for example (page must contain macro – any macro)
      4. Make changes that can be automatically merged, then save the pages with each user
      5. After the second save, all macros will be broken because all attributes have been removed from the "ac:structured-macro" element.

      Can also be replicated by installing Numbered Captions from Marketplace and using those Macros.

      Expected Results

      Macro should be rendered properly.

      Actual Results

      The below exception is thrown in the console:

      [INFO] [talledLocalContainer] [com.ctc.wstx.exc.WstxLazyException] com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character '=' (code 61) (expected a name start character)
      [INFO] [talledLocalContainer]  at [row,col {unknown-source}]: [1,709]
      [INFO] [talledLocalContainer] 	at com.ctc.wstx.exc.WstxLazyException.throwLazily(WstxLazyException.java:45)
      [INFO] [talledLocalContainer] 	at com.ctc.wstx.evt.FilteredEventReader.hasNext(FilteredEventReader.java:72)
      [INFO] [talledLocalContainer] 	at com.atlassian.confluence.content.render.xhtml.XmlFragmentEventReader.hasNext(XmlFragmentEventReader.java:42)
      [INFO] [talledLocalContainer] 	at com.atlassian.confluence.content.render.xhtml.XmlFragmentBodyEventReader.hasNext(XmlFragmentBodyEventReader.java:36)
      [INFO] [talledLocalContainer] 	at com.atlassian.confluence.content.render.xhtml.transformers.DefaultFragmentTransformer.transform(DefaultFragmentTransformer.java:116)
      [INFO] [talledLocalContainer] 	at com.atlassian.confluence.plugins.hipchat.emoticons.marshalling.EmoticonTransformerBase.transform(EmoticonTransformerBase.java:60)
      [INFO] [talledLocalContainer] 	at com.atlassian.confluence.plugins.hipchat.emoticons.marshalling.EmoticonTransformerStorageToEditor.transform(EmoticonTransformerStorageToEditor.java:30)
      [INFO] [talledLocalContainer] 	at com.atlassian.confluence.content.render.xhtml.TransformerChain.transform(TransformerChain.java:33)
      [INFO] [talledLocalContainer] 	at com.atlassian.confluence.content.render.xhtml.PluggableTransformerChain.transform(PluggableTransformerChain.java:39)
      [INFO] [talledLocalContainer] 	at com.atlassian.confluence.content.render.xhtml.DefaultRenderer.render(DefaultRenderer.java:142)
      [INFO] [talledLocalContainer] 	at com.atlassian.confluence.content.render.xhtml.DefaultFormatConverter.convertToEditorFormat(DefaultFormatConverter.java:142)
      [INFO] [talledLocalContainer] 	at com.atlassian.confluence.pages.actions.AbstractPreviewPageAction.getEditorFormattedContent(AbstractPreviewPageAction.java:179)
      [INFO] [talledLocalContainer] 	at com.atlassian.confluence.pages.actions.AbstractEditPageAction.handleVersionConflict(AbstractEditPageAction.java:318)
      [INFO] [talledLocalContainer] 	at com.atlassian.confluence.pages.actions.AbstractEditPageAction.doEdit(AbstractEditPageAction.java:174)
      [INFO] [talledLocalContainer] 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      [INFO] [talledLocalContainer] 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      [INFO] [talledLocalContainer] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      [INFO] [talledLocalContainer] 	at java.lang.reflect.Method.invoke(Method.java:498)

      Notes

      Take the code macro as an example, the broken macro has the following contents in the storage format where the attributes for the main element are missing,

      <ac:structured-macro><ac:parameter ac:name="language">bash</ac:parameter><ac:parameter ac:name="title">test</ac:parameter><ac:plain-text-body><![CDATA[echo "test"]]></ac:plain-text-body></ac:structured-macro>
      

            [CONFSERVER-52591] Automatic merge corrupts macros when XhtmlContent.updateMacroDefinitions is used

            sinan.yildirim247208441 added a comment -

            In our case after disabling 2  Latex Math Modules the pages includes no broken macros after concurrent editing. So the page can be rendered correctly.

            sinan.yildirim247208441 added a comment - In our case after disabling 2  Latex Math Modules the pages includes no broken macros after concurrent editing. So the page can be rendered correctly.

            Is there any status on this issue? I have been getting more support requests on this issue and I it is actually quite critical that Confluence breaks all of the macros on edited pages.

            Jason Boileau added a comment - Is there any status on this issue? I have been getting more support requests on this issue and I it is actually quite critical that Confluence breaks all of the macros on edited pages.

            sinan.yildirim247208441 added a comment -

            Hi Jason,

            exactly, we have the same issue on 6.2.4. But we disabled collaborative editing before.

            sinan.yildirim247208441 added a comment - Hi Jason, exactly, we have the same issue on 6.2.4. But we disabled collaborative editing before.

            I now have a customer with the same issue with collaborative editing enabled. The customer is using Confluence 6.2.4 and gets this error when using LaTeX Math and Scroll Version together.

            Jason Boileau added a comment - I now have a customer with the same issue with collaborative editing enabled. The customer is using Confluence 6.2.4 and gets this error when using LaTeX Math and Scroll Version together.

            Hi, it looks like Ian didn't copy the code example over, here it is:

             

            public class CaptionAnchorTransformer implements Transformer {
            
                private static final Logger log = LoggerFactory.getLogger(CaptionNumberTransformer.class);
            
                private final XhtmlContent xhtmlUtils;
            
                public CaptionAnchorTransformer(
                        XhtmlContent xhtmlUtils)
                {
                    this.xhtmlUtils = xhtmlUtils;
                }
            
                @Override
                public String transform(Reader reader, final ConversionContext ctx) throws XhtmlException {
                    try {
                        String storage = IOUtils.toString(reader);
                        try {
                            return xhtmlUtils.updateMacroDefinitions(storage, ctx, new MacroDefinitionUpdater() {
                                public MacroDefinition update(MacroDefinition macroDefinition) {
                                    return macroDefinition;
                                }
                            });
                        } catch (XhtmlException e) {
                            log.error("Could not complete XHTML transformation due to error: "+e.getMessage());
                            return storage;
                        }
                    } catch (IOException e) {
                        throw new XhtmlException(e);
                    }
                }
            }
            

            That code runs XhtmlContent.updateMacroDefinitions, but returns the macros unchanged.

            It's my customer (add-on user) that had collaborative editing disabled, I can forward your question to him.

            I'm not sure what you mean by snapshots, can you explain?

            Regards,

            Jason

             

            Jason Boileau added a comment - Hi, it looks like Ian didn't copy the code example over, here it is:   public class CaptionAnchorTransformer implements Transformer { private static final Logger log = LoggerFactory.getLogger(CaptionNumberTransformer.class); private final XhtmlContent xhtmlUtils; public CaptionAnchorTransformer( XhtmlContent xhtmlUtils) { this .xhtmlUtils = xhtmlUtils; } @Override public String transform(Reader reader, final ConversionContext ctx) throws XhtmlException { try { String storage = IOUtils.toString(reader); try { return xhtmlUtils.updateMacroDefinitions(storage, ctx, new MacroDefinitionUpdater() { public MacroDefinition update(MacroDefinition macroDefinition) { return macroDefinition; } }); } catch (XhtmlException e) { log.error( "Could not complete XHTML transformation due to error: " +e.getMessage()); return storage; } } catch (IOException e) { throw new XhtmlException(e); } } } That code runs XhtmlContent.updateMacroDefinitions, but returns the macros unchanged. It's my customer (add-on user) that had collaborative editing disabled, I can forward your question to him. I'm not sure what you mean by snapshots, can you explain? Regards, Jason  

            Hi jason41,

            Thanks for raising this issue!

            Could you please clarify the following information?

            1. at step 1 of reproduce, it says "but makes no changes (code below)", could you add more details for this?
            2. could you please share with us the reason to disable collaborative editing?
            3. could you please upload the snapshots if exist?

            Regards,

            Feng Xu

            Feng Xu (Inactive) added a comment - Hi jason41 , Thanks for raising this issue! Could you please clarify the following information? at step 1 of reproduce, it says "but makes no changes (code below)", could you add more details for this? could you please share with us the reason to disable collaborative editing? could you please upload the snapshots if exist? Regards, Feng Xu

              Unassigned Unassigned
              22f09878332c Jason Boileau
              Affected customers:
              6 This affects my team
              Watchers:
              11 Start watching this issue

                Created:
                Updated: