Thought system

Nao

  • Dadman with a boy
  • Posts: 16,082
Re: Thought system
« Reply #30, on November 6th, 2011, 07:12 PM »
That's one of the things I hate about the current thought system on Wedge.org, yeah... ;)

I added a css transition on showing the buttons but it's probably a tad too much... Once I commit, try removing the 'transition' line at the end of index.member.css and tell me what you like best.

Also, I'm doing .php_htmlspecialchars() and .php_unhtmlspecialchars() as required, but I'm not exactly a specialist of wedit::preparsecode(), so would you mind looking into it later...? Just to tell if it's best to use it or not...

95% finished.
Re: Thought system
« Reply #31, on November 6th, 2011, 07:30 PM »
Also, there's an issue with my current logic... I'm preparsing the BBC before storing it, but then I allow for editing posts, which means that if they have BBC, they end up showing HTML tags in the code. Hmm...
I guess I could use the HTML to BBC converter, especially since Wedge only accepts a small subset of very simple bbc tags in thoughts.

I'll probably commit everything before I get to it. I spent many hours stuck in the Parisian traffic, I'm definitely KO tonight. I want to commit and be done with it... Whatever glitches it has.

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
Re: Thought system
« Reply #32, on November 6th, 2011, 07:37 PM »
I would not perform htmlspecialchars on the client side. I would leave it as is, and do it on the server side. Always assume the client is insecure/unsafe.

Strictly speaking, anything that's going to be sent, no matter how indirectly, to the bbc parser 'should' go through preparsecode, and if memory serves, preparsecode does not perform htmlspecialchars anyway, because I seem to recall it's always done ahead of time by other processes.

It's complicated because there are other side matters to attend to with it. preparsecode actually does an insane amount of stuff, IIRC the list in no particular order is:

* convert newlines to br tags (not entirely sure why it does this, I've never fully understood this logic but I'm assuming it's for the benefit of code tags so that you don't try second guessing p tags, and it means if you want a double blank line, you get one)
* validates that anyone using the html bbcode is an admin (or remove the tag otherwise)
* breaks the content of nobbc bbcode so that it won't be parsed (physically convert the brackets to their numeric equivalent)
* attempt to fix table tag hierarchies through regular expressions (table must contain tr, tr must contain td, td must be inside tr, tr must be inside table, list must contain li, li must be inside list)
* convert double space to nbsp+space so they're actually displayed as such
* break instances of [] and [' so that they're not parsed as potential bbcode for speed (e.g. inside people posting code outside of code tags)
* convert /me to the me bbcode
* convert specific colour bbcodes to the generic case (e.g. replace red, blue, etc, bbcode with color=red, color=blue)
* invoke the tag scheme checker to go through img, url and similar tags looking for valid http/s entries and forcing them to have the right scheme
* if images are posted and there is a maximum image size, validate the image's size and rewrite the img bbcode if necessary to include new sizes

It is pretty insane when you think about it! But that's what's required to ensure that any arbitrary posting is safe to be displayed later. (More, in fact, could be done, because it could step through the tags at save time and validate that they are properly nested and so on, and take that burden off parse-bbc)

Long story short, it depends on what you're looking to allow in the thought system. If it's the small list of inline codes, you don't need to invoke the entire preparser, but it will need a subset of the loop at the end of the routine where it splits the post into sections by code tags, most importantly to catch the fixTags call (to sanitise links and/or images posted, though images should probably be rewritten to links anyway!)

You don't need to have it also do the regexps that handle fixing table/list nesting because they're not going to be parsed anyway, so no need to alter them (and I'd suggest not altering the thought for that purpose)

Perhaps there should be a parameter to preparsecode, for inline parsing requirements, where if false, only do what's necessary for inline bbc requirements.
Quote
which means that if they have BBC, they end up showing HTML tags in the code. Hmm...
This is a problem that has affected many, many people in figuring this stuff out. The HTML to BBC converter is not rugged, but if you're only feeding it the inline tags, it's probably enough.
When we unite against a common enemy that attacks our ethos, it nurtures group solidarity. Trolls are sensational, yes, but we keep everyone honest. | Game Memorial

Nao

  • Dadman with a boy
  • Posts: 16,082
Re: Thought system
« Reply #33, on November 6th, 2011, 10:46 PM »
'kay, haven't added preparsecode() to the stuff in the end... This is mainly because I didn't even remember correctly how I was doing things, uh... The only thing that got parsed at cache time was personal_text, while all other free thoughts are parsed at display time. I still think there's an issue with bbcode though... <sigh>

One thing that I should point out is that I was using .escape() to send the data in JS, I forgot that it didn't support UTF, so now it uses (properly) .php_urlencode().

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
Re: Thought system
« Reply #34, on November 6th, 2011, 11:00 PM »
Quote
I still think there's an issue with bbcode though...
Which is probably why preparsecode is needed. I'll take a look in a bit and see what I think is needed.

Nao

  • Dadman with a boy
  • Posts: 16,082
Re: Thought system
« Reply #35, on November 6th, 2011, 11:06 PM »
Take your time, I'll be offline in a few minutes anyway.
Re: Thought system
« Reply #36, on November 7th, 2011, 08:37 PM »
BTW... I woke up :P

Also, there are a few things I mentioned in the changelog topic...
For instance-- how about we rename the system to 'Words'?
It may be less intuitive, though. Because it doesn't start with T(weet) but with W(edge).
I just thought it'd be worth asking...

Friggin' system is taking more time than I want, BTW. I'm currently working on a 'proper' profile template... Long and annoying to test.

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
Re: Thought system
« Reply #37, on November 7th, 2011, 08:43 PM »
Unless we borrow from Facebook and call it a status...

Dismal Shadow

  • Madman in a Box
  • Me: Who is Arantor? Cleverbot: It stands for time and relative dimensions in space.
  • Posts: 1,185
Re: Thought system
« Reply #38, on November 7th, 2011, 08:43 PM »
How about 'protest'? :P
“I will stand on my ground as an atheist until your god shows up...If my irreligious bothers you much, and if you think everything I do is heresy to your god I don't care. Heresy is for those who believe, I don't. So, it isn't heresy at all!


   Jack in, Wedge,
   EXECUTE!

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278

Nao

  • Dadman with a boy
  • Posts: 16,082
Re: Thought system
« Reply #40, on November 7th, 2011, 10:50 PM »
Quote from Arantor on November 7th, 2011, 08:43 PM
Unless we borrow from Facebook and call it a status...
That would imply non-comment thoughts have more weight than comments... I'm not sure I want to do that..?

Anyone?

Dismal Shadow

  • Madman in a Box
  • Me: Who is Arantor? Cleverbot: It stands for time and relative dimensions in space.
  • Posts: 1,185

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
Re: Thought system
« Reply #42, on November 7th, 2011, 11:00 PM »
Haha

@Nao, you're right, of course, it would elevate their apparent standing. Hmm, I got nothing better. :(

Nao

  • Dadman with a boy
  • Posts: 16,082
Re: Thought system
« Reply #43, on November 7th, 2011, 11:16 PM »
I'm assuming 'Words' sounds bad in English, then...?

Dismal Shadow

  • Madman in a Box
  • Me: Who is Arantor? Cleverbot: It stands for time and relative dimensions in space.
  • Posts: 1,185