Attributes cleaning question

Help
Vaclav
2007-08-03
2013-03-05
  • Vaclav

    Vaclav - 2007-08-03

    Hello,

    I’m working on some cms-like system and want to refuse to post some "dirty" stuff into text area.  Your library help me to clean out some tags like <script> etc. But is it possible to clean up something like this (see below)?

    From: <div onclick="dirty_stuff()" style="dirty:stuff">blah-blah</div>
    To: <div>blah-blah</div>

    Thanks.

     
    • Vladimir Nikic

      Vladimir Nikic - 2007-08-03

      Well, not complitely. You may use HtmlCleaner to produce well-formed XML and after that serialize it to JDom for example where you can do what you want.

       
      • Maciej Matecki

        Maciej Matecki - 2008-01-21

        Hello,
        Could You write something more. I work on it a few hours and it's not so easy as it looks like. Could you give example how to do it?
        Regards,
        Maciej Matecki

         
        • Vladimir Nikic

          Vladimir Nikic - 2008-01-21

          HtmlClaner has no ability to remove specific attributes. The only thing you can do with it is to produce well-formed XML out from dirty HTML. With XML, you may do much more things - for details how to remove attributes from XML element, please check JDom or Xml DOM documentation.

          Best, Vladimir.

           
  • Zoran Polic

    Zoran Polic - 2011-02-23

    Hvala na genijalnom parseru i ako mogu da korigujem ovu zadnju sa malko koda ;)

    Version 2.2

    Before - > <table width="884" border="1" bordercolor="#000000" cellpadding="7" cellspacing="0">
                  

     tt = new TagTransformation("table","table",true);
                tt.addAttributeTransformation("width");
                tt.addAttributeTransformation("border");
                tt.addAttributeTransformation("bordercolor");
                tt.addAttributeTransformation("cellpadding");
                tt.addAttributeTransformation("cellspacing");
                transformations.addTransformation(tt);
    

    After - > <table>

    Cheers.

     
  • Vladimir Nikic

    Vladimir Nikic - 2011-02-24

    :)

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks