HTML Macro Cloud - User Guide

The HTML app allows you to incorporate snippets of HTML into your page.  These can include HTML, JavaScript, and CSS which will run inside the macro itself, but does not affect the rest of the page.


Click to View in Marketplace


Demo



Features 

  • Ability to seamlessly incorporate HTML elements, custom styling (CSS) and JavaScript without affecting the rest of the page 
  • Allows for previews to prevent tedious page reloading

Quick Start 

  1. Installation & Setup
    1. The app installation is a standard one for Confluence MarketPlace apps.

  2. Insert the HTML macro into your page and click Insert
    1. (warning) The Sanitize box should be unchecked if you're inserting JavaScript. 
      1. See Security Considerations section for more information.
        1. the macro is rendered in one or two levels of IFrames.  Therefore, you cannot interact w/ the DOM of the parent and should be familiar with the same-origin policy if you are using advanced client-side code.
    2. Specify the height for your macro.  You can leave blank and adjust it later by editing the macro after you've previewed the page.

  3. Add your HTML to the box that's now inserted on your page

  4. Review the macro by viewing the Confluence page or use the "Preview" window in the macro editor.

Security Considerations

Sanitize HTML option

When using the Sanitize option (Sanitize box in macro is checked), only "safe" HTML is allowed (i.e. no JavaScript allowed).  This option will load slightly faster. 

When sanitized is unchecked then JavaScript can be executed by your macro and you can make AJAX requests from your code in the body of the HTML macro.  The sandbox iFrame does not add any CORS-related headers.  However, AJAX requests to services that you do not control may contain CORS response headers that prevent you from using them within the sandbox iFrame.

An administrator can use the "Configure" button for the HTML Macro in the "Manage apps" page to allow or prevent users from creating and viewing unsanitized HTML macros:


X-Frame-Options Response Header

If you try to include an iFrame in an HTML macro it will not work if the server for the src of the iframe sets the X-Frame-Options response header to DENY or SAMEORIGIN (https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options) .  In this situations, the browser console may say, "Refused to display 'https://www.mysite.com' in a frame, because it set 'X-Frame-Options' to 'SAMEORIGIN."  

The X-Frame-Options header value of SAMEORIGIN only allows content to be embedded in an iFrame if the content is from the same origin as the page containing the iframe.  The DENY value will disallow it from any origin.

When a server returns the X-Frame-Options response header the server has explicitly set a content security policy that limits it's content rendering in an iFrame, and the browser is honoring that.  It is a browser security issue and is not something Artemis can control or bypass.  

If you control the remote domain that is serving the src of the iframe, you can disable this setting on that server or you could build a proxy for that domain that strips the header.  Many sites do not want to show up in iFrames for Intellectual Property (IP) or security reasons.

Development Considerations 

When developing JavaScript or other code to add to this app, please note that it is running in an iFrame inside the macro AND an iFrame on the Confluence page. The innermost iFrame is served from our app domain and not from Atlassian. For instance, if you create an HTML form and submit it, you will likely get a response from our domain indicating that it is "Not authenticated." 


Examples 


Related Articles


General Articles