BBCode -> HTML translator is doing [pre] incorrectly

Questions and Answers : Web site : BBCode -> HTML translator is doing [pre] incorrectly
Message board moderation

To post messages, you must log in.

AuthorMessage
Profile Steven Meyer
Avatar

Send message
Joined: 24 Mar 08
Posts: 2333
Credit: 3,428,296
RAC: 0
United States
Message 895413 - Posted: 16 May 2009, 14:08:40 UTC
Last modified: 16 May 2009, 14:09:09 UTC

The BBCode -> HTML translator is doing <pre> incorrectly, adding an extra <br> at the end of each line.

<pre>Application Progress Report deadline Status<br>
------------------ -------- -------------------- ----------------------<br>
Astropulse v5 5.03 59% 6/20/2009 7:27:02 AM Running, high priority<br>
Astropulse v5 5.03 6% 6/20/2009 7:27:02 AM Running<br>
</pre><br>


This results in the post looking like the following, with the extra blank lines.
Application        Progress Report deadline      Status
------------------ -------- -------------------- ----------------------
Astropulse v5 5.03      59% 6/20/2009 7:27:02 AM Running, high priority
Astropulse v5 5.03       6% 6/20/2009 7:27:02 AM Running

Is it possible to fix this?


Note: The BBcode [pre] is properly translating into HTML as <pre>.

Note Too: Why on Earth did they invent and use something sort of like HTML but not? Why not just use HTML???
ID: 895413 · Report as offensive
Profile Michael Roberts
Volunteer tester
Avatar

Send message
Joined: 20 Aug 99
Posts: 2588
Credit: 791,775
RAC: 0
Germany
Message 895463 - Posted: 16 May 2009, 16:14:57 UTC - in response to Message 895413.  
Last modified: 16 May 2009, 16:21:39 UTC

The BBCode -> HTML translator is doing <pre> incorrectly, adding an extra <br> at the end of each line. ...

This is a long-standing problem which has also been irritating me -- see this post in Einstein@Home for example.

Note Too: Why on Earth did they invent and use something sort of like HTML but not? Why not just use HTML???

The motivation for using bbcode is:

// Functions that process user-supplied text (e.g. messages)
// prior to displaying it to users.
// Goals:
// - Security (don't send evil javascript)
// - obey user preferences
// - improve formatting (e.g., convert newlines to <br> tags)

Clearly the last aim is being misapplied in some circumstances.
I am making another attempt to track this down...
ID: 895463 · Report as offensive
Profile Michael Roberts
Volunteer tester
Avatar

Send message
Joined: 20 Aug 99
Posts: 2588
Credit: 791,775
RAC: 0
Germany
Message 895486 - Posted: 16 May 2009, 17:27:53 UTC - in response to Message 895463.  
Last modified: 16 May 2009, 17:28:50 UTC

Please see ticket 891.
ID: 895486 · Report as offensive
Profile Steven Meyer
Avatar

Send message
Joined: 24 Mar 08
Posts: 2333
Credit: 3,428,296
RAC: 0
United States
Message 895972 - Posted: 17 May 2009, 17:05:48 UTC
Last modified: 17 May 2009, 17:08:46 UTC

Here is a simple solution...
<style type="text/css">pre br {display:none}</style>

ID: 895972 · Report as offensive
Profile Steven Meyer
Avatar

Send message
Joined: 24 Mar 08
Posts: 2333
Credit: 3,428,296
RAC: 0
United States
Message 895980 - Posted: 17 May 2009, 17:14:56 UTC - in response to Message 895463.  


The motivation for using bbcode is:

// Functions that process user-supplied text (e.g. messages)
// prior to displaying it to users.
// Goals:
// - Security (don't send evil javascript)
// - obey user preferences
// - improve formatting (e.g., convert newlines to <br> tags)

Clearly the last aim is being misapplied in some circumstances.
I am making another attempt to track this down...


Sounds like a lot more work to re-invent most of HTML than it would be to simply excise all occurrences of <script ...> ... </script>
ID: 895980 · Report as offensive
OzzFan Crowdfunding Project Donor*Special Project $75 donorSpecial Project $250 donor
Volunteer tester
Avatar

Send message
Joined: 9 Apr 02
Posts: 15691
Credit: 84,761,841
RAC: 28
United States
Message 896075 - Posted: 17 May 2009, 20:26:34 UTC - in response to Message 895980.  


The motivation for using bbcode is:

// Functions that process user-supplied text (e.g. messages)
// prior to displaying it to users.
// Goals:
// - Security (don't send evil javascript)
// - obey user preferences
// - improve formatting (e.g., convert newlines to <br> tags)

Clearly the last aim is being misapplied in some circumstances.
I am making another attempt to track this down...


Sounds like a lot more work to re-invent most of HTML than it would be to simply excise all occurrences of <script ...> ... </script>


BBCode is also used on a lot of sites to prevent HTML savvy users from writing in code that they shouldn't. BBCode gives forum managers the power to control how much code to use and what not to use, whereas straight HTML does not provide those luxuries. For instance, I visit one site that only uses parts of BBcode and not others (users are not allowed to embed images, and use strikeout text).
ID: 896075 · Report as offensive
Profile Steven Meyer
Avatar

Send message
Joined: 24 Mar 08
Posts: 2333
Credit: 3,428,296
RAC: 0
United States
Message 896124 - Posted: 17 May 2009, 21:19:52 UTC - in response to Message 896075.  
Last modified: 17 May 2009, 21:22:07 UTC


BBCode is also used on a lot of sites to prevent HTML savvy users from writing in code that they shouldn't. BBCode gives forum managers the power to control how much code to use and what not to use, whereas straight HTML does not provide those luxuries. For instance, I visit one site that only uses parts of BBcode and not others (users are not allowed to embed images, and use strikeout text).


No bold, no italic, no underline?

My goodness, was that site paranoid or what?

There is no security threat of any sort in allowing such formatting.

Images are actually a bigger threat from DOS attacks on users with slow network connections, and from IP trapping.


No Script
ID: 896124 · Report as offensive
OzzFan Crowdfunding Project Donor*Special Project $75 donorSpecial Project $250 donor
Volunteer tester
Avatar

Send message
Joined: 9 Apr 02
Posts: 15691
Credit: 84,761,841
RAC: 28
United States
Message 896250 - Posted: 18 May 2009, 2:02:27 UTC - in response to Message 896124.  

Bold, italic and underline were all allowed. Just no images and no strikeout text. Some network/forum administrators wish to have fine-grain control over their servers, and everyone has their own ideals on how to run a network/forum.
ID: 896250 · Report as offensive
Profile Steven Meyer
Avatar

Send message
Joined: 24 Mar 08
Posts: 2333
Credit: 3,428,296
RAC: 0
United States
Message 896397 - Posted: 18 May 2009, 12:51:23 UTC

Whoot!
No extra
blank lines
here!


Thanks guys!

ID: 896397 · Report as offensive
Profile Michael Roberts
Volunteer tester
Avatar

Send message
Joined: 20 Aug 99
Posts: 2588
Credit: 791,775
RAC: 0
Germany
Message 896567 - Posted: 18 May 2009, 19:11:11 UTC - in response to Message 896397.  
Last modified: 18 May 2009, 19:15:43 UTC

Whoot! ... Thanks guys!

You're welcome!

Sounds like a lot more work to re-invent most of HTML than it would be to simply excise all occurrences of <script ...> ... </script>

No. The challenges of allowing an acceptable subset of user-specified html are daunting. Just for starters:

  • not just script is involved: you would also need to disallow style, object, form tags, onclick etc attributes (i.e. fairly accurate parsing of every tag in the input), ...
  • you would need to convert html to xhtml
  • you would need to deal with invalid constructs like <b>...<i>...</b>...</i> or a start tag without its corresponding end tag (just <pre> for example)
  • you would need to make sure that the emitted code validates correctly
  • even if it validates, it will not necessarly work correctly in all the browsers that are being used


On the other hand it is easy to disable html input -- just escape the introductory '<'. The BBCode has a very simple structure. Any invalid or unrecognised items appear as plain text. Users who check what they are submitting (regrettably by no means all) can see the problem and correct it.

ID: 896567 · Report as offensive
Profile Steven Meyer
Avatar

Send message
Joined: 24 Mar 08
Posts: 2333
Credit: 3,428,296
RAC: 0
United States
Message 896596 - Posted: 18 May 2009, 19:55:17 UTC - in response to Message 896567.  
Last modified: 18 May 2009, 19:55:36 UTC

No. The challenges of allowing an acceptable subset of user-specified html are daunting....


All that you say is true, still... as you say those of us who check our posts using ( Preview ) will see the problem before the post is submitted, and even those who do not will still be able to hit ( Edit ). This applies even if the user submits HTML ( <pre> instead of
). 

Which reminds me, is there a way to escape the opening square bracket so that it is not interpreted?
The only reason you can see the one above is because I didn't put 
... oops .... I just did!
ID: 896596 · Report as offensive
Profile Michael Roberts
Volunteer tester
Avatar

Send message
Joined: 20 Aug 99
Posts: 2588
Credit: 791,775
RAC: 0
Germany
Message 896619 - Posted: 18 May 2009, 20:30:20 UTC - in response to Message 896596.  

... is there a way to escape the opening square bracket so that it is not interpreted?

Not as far as I know - mostly people start with a curly brace instead {pre] or add a space [ pre]. Some bbcode implementations seem to allow escaping with '\', but not ours. You would then need to escape the combination '\[' and so on... I think the best way to do it would be define [sqb] (or whatever) as '[', since we would not be messing up the handling of any other characters.

oops .... I just did!

LOL.
ID: 896619 · Report as offensive
Profile Steven Meyer
Avatar

Send message
Joined: 24 Mar 08
Posts: 2333
Credit: 3,428,296
RAC: 0
United States
Message 896624 - Posted: 18 May 2009, 20:33:52 UTC - in response to Message 896619.  

What is that ->
ID: 896624 · Report as offensive
Profile Steven Meyer
Avatar

Send message
Joined: 24 Mar 08
Posts: 2333
Credit: 3,428,296
RAC: 0
United States
Message 896628 - Posted: 18 May 2009, 20:36:26 UTC - in response to Message 896619.  

How about &lsqbr;pre&rsqbr;
ID: 896628 · Report as offensive
Profile Gundolf Jahn

Send message
Joined: 19 Sep 00
Posts: 3184
Credit: 446,358
RAC: 0
Germany
Message 896646 - Posted: 18 May 2009, 20:57:09 UTC - in response to Message 896596.  

...Which reminds me, is there a way to escape the opening square bracket so that it is not interpreted?

From http://setiathome.berkeley.edu/bbcode.php:
If you don't close a tag or don't specify a parameter correctly, the raw tag itself will display instead of the formatted text.


I use that to show BBCode tags without using a curly brace instead {pre] or adding a space by inserting [b][/b], which results in [pre]...[/pre]. :-)

Gruß,
Gundolf
Computer sind nicht alles im Leben. (Kleiner Scherz)

SETI@home classic workunits 3,758
SETI@home classic CPU time 66,520 hours
ID: 896646 · Report as offensive
Profile Michael Roberts
Volunteer tester
Avatar

Send message
Joined: 20 Aug 99
Posts: 2588
Credit: 791,775
RAC: 0
Germany
Message 896659 - Posted: 18 May 2009, 21:30:02 UTC - in response to Message 896646.  

... inserting [b][/b], which results in [pre]...[/pre]. :-)

Clever man!
ID: 896659 · Report as offensive
Profile Michael Roberts
Volunteer tester
Avatar

Send message
Joined: 20 Aug 99
Posts: 2588
Credit: 791,775
RAC: 0
Germany
Message 896661 - Posted: 18 May 2009, 21:36:56 UTC - in response to Message 896624.  

What is that ->

It is "Phoenix" by Sabine Betschke (copyright, used with permission.) I think of it as the closed eye of a phoenix. Apart from the fact that I just like it, the name matches my team, Phoenix Rising.
ID: 896661 · Report as offensive
Profile Steven Meyer
Avatar

Send message
Joined: 24 Mar 08
Posts: 2333
Credit: 3,428,296
RAC: 0
United States
Message 896666 - Posted: 18 May 2009, 21:48:40 UTC

Cool...
[[b][/b]pre]...[/pre] = [pre]...[/pre]
ID: 896666 · Report as offensive
Profile Gundolf Jahn

Send message
Joined: 19 Sep 00
Posts: 3184
Credit: 446,358
RAC: 0
Germany
Message 896669 - Posted: 18 May 2009, 21:52:34 UTC - in response to Message 896666.  

Cool...
[[b][/b]pre]...[/pre] = [pre]...[/pre]

Wow, that are many b's in the reply window ;-)
ID: 896669 · Report as offensive
Profile Steven Meyer
Avatar

Send message
Joined: 24 Mar 08
Posts: 2333
Credit: 3,428,296
RAC: 0
United States
Message 896677 - Posted: 18 May 2009, 22:04:18 UTC - in response to Message 896669.  

Cool...
[[b][/b]pre]...[/pre] = [pre]...[/pre]

Wow, that are many b's in the reply window ;-)

Yep
ID: 896677 · Report as offensive

Questions and Answers : Web site : BBCode -> HTML translator is doing [pre] incorrectly


 
©2024 University of California
 
SETI@home and Astropulse are funded by grants from the National Science Foundation, NASA, and donations from SETI@home volunteers. AstroPulse is funded in part by the NSF through grant AST-0307956.