Search code examples
configurationliferayliferay-6

What is the meaning of this tag <sanitize> in portal-model-hints.xml?


I am curious as to what would the following line mean in file portal-model-hints.xml:

<field name="title" type="String">
    <sanitize content-type="text/plain" modes="ALL" />
</field>

So here are my questions:

  1. What changes does this <sanitize> tag make to the field?
  2. what does the attributes mean?
  3. What are the different types of modes?
  4. and are there any other attributes for this tag?

I have gone through the only wiki which deals with model-hints.

Thanks


Solution

  • It seams to me that this hint says the Liferay portal to use sanitizer before storing this field into the database. Sanitizers are filtering elements that "sanitize" web content (usually HTML or javascript code) so that it doesn't contain unappropiate content like javascript malicious code or swearwords, for example. You can find more info on sanitizers here.

    So answers to your questions are:

    What changes does this tag make to the field? - Field should be sanitized

    what does the attributes mean? - Field is supposed to contain plain text and sanitizer will use the ALL sanitizing mode

    What are the different types of modes? - You can find that there are three modes ("ALL", "BAD_WORDS" and "XSS") so far in Sanitizer.java

    And are there any other attributes for this tag? - I have't managed to find any other attribute