1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Preventing unclosed tags affecting the rest of the site (HTML/javascript only solution)

Discussion in 'HTML & Website Design' started by qwikad.com, Oct 9, 2015.

  1. #1
    Is there such a thing as closing all tags using HTML/javascript only? I know it can be done in php using the html purifier, for instance, but a php solution is out of question right now. What I need is a code I can place at the end of the posts that will prevent affecting the rest of the site if there are unclosed HTML tags within those posts. The posts may contain all kinds of unclosed HTML tags. From none to a dozen.
     
    qwikad.com, Oct 9, 2015 IP
  2. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,998
    Best Answers:
    253
    Trophy Points:
    515
    #2
    Why not just make sure you have valid code in the first place?

    Though if this is user posts, that's one of the many reasons bbcode exists; you use regex to match the bbcode and turn it into markup -- if a closing bbcode tag is missing, it doesn't get converted.
     
    deathshadow, Oct 9, 2015 IP
    sarahk likes this.
  3. qwikad.com

    qwikad.com Illustrious Member Affiliate Manager

    Messages:
    7,151
    Likes Received:
    1,656
    Best Answers:
    29
    Trophy Points:
    475
    #3
    And I do some of it, but there comes a point that no regex will be able to help. For instance, somebody posted something like this recently:

    
    
    <div style="text-align: center;"> <font size=4> <font size=4> It's<br>Some text <br> <br>Some text <br> <br>Some text <br> <br>Many Some text <br> <br>Some text <br> <br> <br> <br> <a
    href="http:// somelink.com "> <span
    style="color: rgb(255, 0, 0); text-decoration: underline;"> Some text<br>Some text </span> </a> <br> <br> <br> <br> <img style="max-width:100%; height:auto;" style="width: 1087px; height: 559px;"
    alt="bear hunter sticker"
    src=" http:// someimage.com/1.JPG "> <br> <br> <span style="text-decoration: underline;"> <span
    style="text-decoration: underline;"> </span> </span> </font> </font> <a
    href=" http:// somelink.com "> <big
    style="text-decoration: underline;"> <font size=4> <font size=4> <font size=4> </font> </font> </font> </font> </a> <br> <br> <br> <br> </div> <p></p>
    
    
    Code (markup):
    As you can see it's a complete mess. On one hand I'd love to make sure that only valid codes are entered, on the other hand when money is involved I want people to enter whatever they want since they are paying for it. So, I just wish I could somehow close all unclosed tags and forget about it.
     
    qwikad.com, Oct 9, 2015 IP
  4. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,998
    Best Answers:
    253
    Trophy Points:
    515
    #4
    Ok, what/how are they "posting"?

    Honestly, if they are writing THAT for HTML what *****ing business do they have posting jack ****? That's a case of where I'd tell that person they're not allowed to post until they get a plowing clue, or just walk away from the project as no amount of money is worth dealing with such a mouth-breathing dumbass who has their head wedged up 1997's backside.

    There's handholding, and then there's putting up with bullshit. That code treads squarely into the latter and that's time to take out the paddle, smack them on the ass, the slap the dunce cap on their head to sit them in the corner while the rest of the class laughs at them.

    You can only mollycoddle people so far before it treads into "You know what, go flip burgers"
     
    deathshadow, Oct 9, 2015 IP
  5. sarahk

    sarahk iTamer Staff

    Messages:
    28,500
    Likes Received:
    4,460
    Best Answers:
    123
    Trophy Points:
    665
    #5
    give them ckeditor or something like that to input their html - it does a great job of stripping the tags and attributes you don't want and closing the tags etc even when people edit the source directly.
     
    sarahk, Oct 10, 2015 IP
    webcosmo likes this.
  6. webcosmo

    webcosmo Notable Member

    Messages:
    5,840
    Likes Received:
    153
    Best Answers:
    2
    Trophy Points:
    255
    #6
    Validate the post, and warn the user, probably also send a link with html tutorials?
     
    webcosmo, Oct 13, 2015 IP