-
Bug
-
Resolution: Unresolved
-
Low
-
None
-
4.3.7, 5.0, 5.1, 5.8.4
-
22
-
Severity 3 - Minor
-
3
-
The allowable protocols for external links was expanded in this task: https://jira.atlassian.com/browse/CONF-24665
The regex used is still too restrictive for some customers. And should be expanded to match the allowable characters as per the RFC whilst continuing to restrict dangerous protocols.
Workaround
- Find <confluence_install>/confluence/WEB-INF/lib/confluence-4.x.x.jar and extract the contents of this file somewhere
- Locate and edit com/atlassian/confluence/content/render/xhtml/antisamy-confluence-storage.xml
- Around line 54 or so there should be a regex matching file, smb, irc, etc, similar to the following line:
<regexp name="offsiteURL" value="(\s)*(((ht|f)tp(s?)|file|smb|irc|news|nntp|feed|cvs|git|svn|mvn|ssh|itms|notes)://|mailto:)[\p{L}\p{N}/]+[\p{L}\p{N}\p{Zs}\.\#@\$%\+&;:\-_~,\?=/!\(\)]*(\s)*" />
- Add the desired protocol to this list (e.g. 'hansoft' or 'exp2') to this list and save. Should look like this
<regexp name="offsiteURL" value="(\s)*(((ht|f)tp(s?)|file|smb|irc|news|nntp|feed|cvs|git|svn|mvn|ssh|itms|notes)://|mailto:|exp2:)[\p{L}\p{N}/]+[\p{L}\p{N}\p{Zs}\.\#@\$%\+&;:\-_~,\?=/!\(\)]*(\s)*" />
- Place the modified XML file in the following directory: <confluence-install>/confluence/WEB-INF/classes/com/atlassian/confluence/content/render/xhtml/ (create the directories if they do not exist)
- Restart Confluence
Please note that allowing Confluence to save/render more link types can be a potential security risk. Additionally, this workaround is not a supported operation and may not be applicable to future upgrades as the product changes.
Workaround with Collaborative Editing On
- In addition to the steps above, as of 6.2.2, it's possible to do the following
- Find <confluence_install>/confluence/WEB-INF/atlassian-bundled-plugins/confluence-collaborative-editor-plugin-x.y.z.jar
- Create a backup of the jar somewhere in a different directory.
- Extract the contents and locate the two files js/util/is-valid-uri.js and js/util/is-valid-uri-min.js.
- In both files, locate the list of allowed protocols (you can search for mailto: for example), and add the required protocols to that list separated by |. Proper JS Regex escaping is required here, so if the protocol is my-protocol1:// for example, it should be entered as
my-protocol1:\\/\\/
- Repackage the jar
- Backup and the Plugin Cache directories
- Clear out the Plugin Cache directories
- Backup <confluence-install>/temp folder
- Clear out the contents of the <confluence-install>/temp folder (make sure the folder still exists)
- Start Confluence
Please note that allowing Confluence to save/render more link types can be a potential security risk. Additionally, this workaround is not a supported operation and may not be applicable to future upgrades as the product changes.
Hello! Just voicing my support for getting a way to configure this for Confluence Cloud instances.
Our company has an internal tool relying on custom-protocol links and being able to share these links in our Confluence-based documentation would be a huge deal.