Forum Discussion

iahiqosolutions's avatar
12 years ago

REST API. Getting error during posting new message

Hello guys,

 

I get the following error when I'm try to post new message on a board via Lithium REST API:

 

message.body: Your post has been changed because invalid HTML was found in the message body. The invalid HTML has been removed. Please review the message and submit the message when you are satisfied.

 

My orginal text is the following:

 

<p><p class="bold">Text of description.</p></p><p>Text of description.</p><p><p class="italic">Text of description.</p></p><p>Text of description.</p><p><p class="underline">Text of description.</p></p><p>Text of description.</p><p><p>Text of description.</p></p>


As far as I remember Lithium has the following constraints on using HTML code:

 

basicHTMLTags = br,p:class,a:href|target|rel|title,div,li-video:vid|align|size|width|height|originalwidth|originalheight|thumbnail|uploading|external|cid|pid|unm,li-spoiler

 

simpleHTMLTags = a:href|target|rel|title,b,i,p:align|class,u,br,em,hr,ol,li,ul,pre,div:align|class,img:src|width|height|alt|title|border|align,font:face|size|color,span:class,span:style,center,strike,strong,blockquote:dir,li-video:vid|align|size|width|height|originalwidth|originalheight|thumbnail|uploading|external|cid|pid|unm,table:cellspacing|cellpadding|border,tr,td,li-spoiler

 

superSimpleHTMLTags = a:href|target|rel|title,b,i,p:align|class,u,br,em,hr,ol,li,ul,pre,div:align|class,font:face|size|color,span:class,center,strike,strong,blockquote:dir,li-video:vid|align|size|width|height|originalwidth|originalheight|thumbnail|uploading|external|cid|pid|unm,li-spoiler

 

As you can see my original text is fully matched basicHTMLTags.

So I don't understand why this wired error is occurred. Could anyone can explain me?

 

  • AllenS's avatar
    AllenS
    12 years ago

    iahiqosolutions wrote:

    Hello AllenS,

     

    The HTML code that you suggested is working perfectly well,

    but there is a moment which is not clear for me:
    How can I switch HTML set that is currently used by Lithium(superSimpleHTMLTags, simpleHTMLTags, basicHTMLTags)?

    Can I create my own HTML tag set?(for example, I want to allow to use each user tag "img")

     


    Hi iahiqosolutions,

     

    I'm glad to hear that worked out!

     

    Changing which tags the HTML parser allows is something the Lithium team will have to adjust for you on the backend. If you file a support case with the changes you would like to make we can go ahead and set that up on stage for you to review. You can submit a support case by accessing the Lithium support portal on the Lithosphere or by e-mailing support@lithium.com directly.

     

    Have a great day!

  • AllenS's avatar
    AllenS
    Khoros Alumni (Retired)

    Hi iahiqosolutions,

     

    It looks like the HTML you are using isn't valid. When I when put it through an HTML validator it returns several errors, specifically around putting a p tag inside of another p tag. When I use this in a normal post on one of our test communities I get the same error and the HTML is changed to look like this:

     


    <p class="bold">Text of description.</p>
    <p>Text of description.</p>
    <p class="italic">Text of description.</p>
    <p>Text of description.</p>
    <p class="underline">Text of description.</p>
    <p>Text of description.</p>
    <p>Text of description.</p>


     

    You are correct that we do have an HTML parser that limits what tags users can use in posts. However, there is also a validation step that validates the HTML and removes anything that is invalid (such as HTML that is incorrectly formatted or tags that don't exist). This is the cause of the error you are running into. Can you try using the above HTML I pasted and seeing if that works out?

     

     

    Have a great day!

    • Hello AllenS,

       

      The HTML code that you suggested is working perfectly well,

      but there is a moment which is not clear for me:
      How can I switch HTML set that is currently used by Lithium(superSimpleHTMLTags, simpleHTMLTags, basicHTMLTags)?

      Can I create my own HTML tag set?(for example, I want to allow to use each user tag "img")

       

      • AllenS's avatar
        AllenS
        Khoros Alumni (Retired)

        iahiqosolutions wrote:

        Hello AllenS,

         

        The HTML code that you suggested is working perfectly well,

        but there is a moment which is not clear for me:
        How can I switch HTML set that is currently used by Lithium(superSimpleHTMLTags, simpleHTMLTags, basicHTMLTags)?

        Can I create my own HTML tag set?(for example, I want to allow to use each user tag "img")

         


        Hi iahiqosolutions,

         

        I'm glad to hear that worked out!

         

        Changing which tags the HTML parser allows is something the Lithium team will have to adjust for you on the backend. If you file a support case with the changes you would like to make we can go ahead and set that up on stage for you to review. You can submit a support case by accessing the Lithium support portal on the Lithosphere or by e-mailing support@lithium.com directly.

         

        Have a great day!