Advertisement:

Author Topic: BBCodes: Special characters cause parameters not to be separated  (Read 2480 times)

Offline Yoshi

  • Customizer
  • SMF Hero
  • *
  • Posts: 8,351
  • Gender: Male
Hi!

After writing a BBCode which accepts "%" in a parameter, I found this bug (with MrPhil's help, really).

Take a look at this topic which should explain it all:
http://www.simplemachines.org/community/index.php?topic=474519.msg3317607#msg3317607

Basically if I do something like this:

Code: [Select]
[catbar width=50% icon=http://blah.com/icon.png]Test[/catbar]
The space between the % and icon= doesn't get recognized and the parameters get merged into "width".

If I switch the two, like this:
Code: [Select]
[catbar icon=http://blah.com/icon.png width=50%]Test[/catbar]It works.
My Mods / Mod Builder - A tool to easily create mods! / GitHub profile /
Quote
<FLAMER> Marketing is about to get into drug activities maybe... but we will see about that later on :P
<Yoshi2889> We're getting free drugs?
<CoreISP> He's talking about caffeine man, damn pen lifter.

Offline Yoshi

  • Customizer
  • SMF Hero
  • *
  • Posts: 8,351
  • Gender: Male
Re: BBCodes: Special characters cause parameters not to be separated
« Reply #1 on: May 26, 2012, 06:06:04 AM »
Any updates on this?
My Mods / Mod Builder - A tool to easily create mods! / GitHub profile /
Quote
<FLAMER> Marketing is about to get into drug activities maybe... but we will see about that later on :P
<Yoshi2889> We're getting free drugs?
<CoreISP> He's talking about caffeine man, damn pen lifter.

Offline Arantor

  • SMF Legend
  • *********
  • Posts: 51,160
    • wedgebook on Facebook
Re: BBCodes: Special characters cause parameters not to be separated
« Reply #2 on: May 26, 2012, 08:00:43 AM »
Since there were no replies, there are no updates...

In any case, the bug isn't actively present in SMF in the sense that nothing in SMF currently as distributed is broken - all the supplied features work, and that new code is tricky.

What you're asking for is actually a non-trivial change to the thousand or so active lines in the BBC parser.

Online emanuele

  • Developer
  • SMF Super Hero
  • *
  • Posts: 12,157
  • Gender: Male
  • Because Orange is Orange
Re: BBCodes: Special characters cause parameters not to be separated
« Reply #3 on: May 26, 2012, 10:05:57 AM »
That not exactly a bug.
You are using both parameters as optional and that is not supported by SMF.

See the quote tag for an example.
If both are optional you have to define at least three tags:
1) one without any parameter,
2) one with only width (for example),
3) and one with icon non-optional and width optional.

Arantor was faster... :P

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

Offline MrPhil

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 6,803
Re: BBCodes: Special characters cause parameters not to be separated
« Reply #4 on: May 26, 2012, 10:17:41 AM »
Why can't all parameters be optional? What I'm hearing is that "optional" isn't entirely so. If that's not a bug, then where do you draw the line? Is this a major SMF design flaw? To say "nothing is broken" is not quite on the level... what should be reasonably expected to work isn't working and at a minimum requires documenting.
Please do not PM me with support questions, unless I ask you to. Unsolicited PMs for support will be ignored. It's best to have questions and answers in public, so others can research a problem and learn about it without having to ask the question yet again. Thank you!
FAQs | SMF 1.1 fixes | Project ideas
-= From the ashes shall rise a sooty tern =-

Offline Arantor

  • SMF Legend
  • *********
  • Posts: 51,160
    • wedgebook on Facebook
Re: BBCodes: Special characters cause parameters not to be separated
« Reply #5 on: May 26, 2012, 10:19:55 AM »
Thing is, nothing is 'broken'. It is working as it was designed to work. Whether that's a bad design is another question entirely.

The reason for it is performance. The more parameters you have that are optional, the more permutations have to be accounted for. This is why, for example, there are 5 separate instances of the quote bbc, multiple instances of img bbc, for the discrete list of supported parameters. If you were to separate it into a single all-in-one as you're proposing, it would actually be quite a bit slower than it currently is. (I know, I've tried.)

Online emanuele

  • Developer
  • SMF Super Hero
  • *
  • Posts: 12,157
  • Gender: Male
  • Because Orange is Orange
Re: BBCodes: Special characters cause parameters not to be separated
« Reply #6 on: May 26, 2012, 10:34:42 AM »
Why can't all parameters be optional? What I'm hearing is that "optional" isn't entirely so. If that's not a bug, then where do you draw the line?
I draw the line exactly where the implementation is done in a certain way for a certain purpose.
If something is done for that reason, then it's not a bug, but a feature request.

Is this a major SMF design flaw?
The fact that parse_bbc would need "a bit" of reqork I think it's as old as SMF.
Call it a "major design flaw"...well, it works and you are using it every day I don't see it so major...

To say "nothing is broken" is not quite on the level... what should be reasonably expected to work isn't working and at a minimum requires documenting.
It is working.
You cannot define all parameters as optional, it's enough to add a new tag without parameters...I don't think it's so overwhelming for a developer...the fact that most likely it's not documented anywhere is another problem. :P

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

Online emanuele

  • Developer
  • SMF Super Hero
  • *
  • Posts: 12,157
  • Gender: Male
  • Because Orange is Orange
Re: BBCodes: Special characters cause parameters not to be separated
« Reply #7 on: June 17, 2012, 04:34:11 AM »
Ah, for the record (I didn't consider it before) there is also another option: use a custom validation function (the same done with the tag img). :)

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.