Jump to content

How to restrict using veeeery long words on comments section


vadimmil
 Share

Recommended Posts

Hi!

I'm testing a news site, build on Processwire. We use standard comments system, provided by PW. I found out, that user can easily crash the whole makeup just with a veeery looong wooord comment. 

59ac68a5d4081_FireShotCapture48-Apple_-http___localhost_puls_siri-1_.thumb.png.2cd20169febc4587c1fe1aa4f151fd27.png

 What is the best approach (except pre-moderation of comments) to deal with this problem?

Link to comment
Share on other sites

Okey, okey, I'm just stupid enough not to know about word-break (yeah, I know, I know, guys, stop laughing). Just added this to CSS:

.CommentText p {
    max-width: 838px;
    word-break: break-word;

}

BUT. Still looking for a jQuery-based solution to do the job on the fly. There are a lot of code examples, dealing with characters/words number, but none of them can stop user from entering a veery loong stuupid word)))

Link to comment
Share on other sites

Hej,

some ideas:

If you would consider such input as spam which does not really deserve proper display you could just cut it off inside the parent box with CSS: overflow: hidden;

Another quick hack would be to insert the invisible character ­ after every so many characters in that "word", so that the layout does not break / the word breaks so it fits into the box. This character is invisible but it tells the browser that the word is allowed to break at that point.
Have a look here and see what it does: https://jsbin.com/pipefid/edit?html,output !
I'd do this on the server side ...

You could enhance this to some "real" hyphenation algorithm ... more or less sophisticated. As time and money allows ;P

EDIT:

I think often it is URLs that blow up the boxes - you could create a Textformatter which replaces long urls with a shortened version
<a href="actual URL">shorter URL</a>

cheers!

 

  • Like 2
Link to comment
Share on other sites

9 hours ago, vadimmil said:

word-break: break-word;

It's good practice to use this any time you have a container of limited width and content from an external source (like comments or an RSS feed) or perhaps where a content author may include a link, which can often be long enough to break a layout. 

  • Like 1
Link to comment
Share on other sites

@AndZyk, thanks a lot! I'll read about this property! Suppose, I'll need to read one/two new editions relating CSS)))

11 hours ago, DaveP said:

It's good practice to use this any time you have a container of limited width and content from an external source (like comments or an RSS feed) or perhaps where a content author may include a link, which can often be long enough to break a layout. 

I see it now. Thanks for mentioning it. It's my first site with any user input, so, I think, I should check some common security and UI approaches.

19 hours ago, blynx said:

EDIT:

I think often it is URLs that blow up the boxes - you could create a Textformatter which replaces long urls with a shortened version
<a href="actual URL">shorter URL</a>

cheers!

 

And now - URLs! I've forgotten about them at all! Thanks, will test the form again)))

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...