Is there a way to prevent external links from being used in image/link elements?
Also is there a way to limit attributes that can be used in those elements?
No, there isn’t.
How would you imagine it working? Like preventing the user from saving a page if it has some external links? That seems a bit harsh, no? Maybe you’re using the WYSIWYG editor but remember that the Wiki editor can be used too.
Actually there could be one possibility which would be to disallow the “url:” prefix for links (in XWiki Syntax 2.1+). so if you add a link it would be considered as the name of a page. But not sure that’s what you want…
So we need more details about your need!
One of our clients, requires external links or resources like images to be disabled. And it is a demand I cannot argue with . What I’m thinking about is
- using script on DOMContentLoaded to fix this stuff.
- filtering renderedContent just before printing it in skin template. (I allready sanitize renderedContent with antisamy in that place, to get rid of unwanted/unallowed attributes etc.)
ok so what you can do is implement an Event Listener that is called before the save and (DocumentUpdatingEvent) and modify the XDOM for the links at that time.
Sounds like a plan, will give it a try, thanks ! And I think I can do the same with comments