The AntiSamy portlet is meant to prevent XSS type attacks. One side effect however is that if an HTML target is used, then the portlet will remove it upon publishing the content.
Steps to Reproduce
- Create Web Content
- Embed a link with a target of _blank
- Publish the content.
- View the content in a web content display portlet, and verify that it opens a new window/tab.
- Download and deploy AntiSamy from Liferay Marketplace.
- Repeat steps 1-3.
- You'll now see that the content opens in the same window instead of a new window/tab.
- Edit web content; click on Source and you'll see that the target has been removed.
- Re-add the target and Publish.
- Go back to Edit the web content; click on Source and you'll see that target has been removed once again.
This behavior is intentional. The Liferay platform uses AntiSamy's default configuration XML, the
sanitizer-configuration.xml, which by default scrubs the target attribute because it could possibly expose a XSS risk.
However, you may configure the AntiSamy's configuration file to allow the target attribute to work.
An example of configuring the xml file that may work is described here: XSS Filter issue with the target attribute of the a tag.
As this would be a customization, please keep a backup of the original AntiSamy portlet, or extend it if possible.