Skip to main content
Topic: BBC Parsing (Read 38852 times) previous topic - next topic
0 Members and 2 Guests are viewing this topic.

Re: BBC Parsing

Reply #105

What are some common tags that get disabled in signatures?

Re: BBC Parsing

Reply #106

No idea...
I usually don't disable any. O:-)
Bugs creator.
Features destroyer.
Template killer.

Re: BBC Parsing

Reply #107

I guess its the ones that make them obnoxious ... font, size, color, image ... and I can't really see a need for footnote, spoiler or member in there either.  My .02
Last Edit: October 10, 2015, 05:57:10 pm by Spuds

Re: BBC Parsing

Reply #108

I wonder what a footnote looks like in the news or signatures.

I guess like this...

Re: BBC Parsing

Reply #109

Don't you dare try size, font and color :P

Re: BBC Parsing

Reply #110

I already know what they look like. Try footnote and spoiler in the news ;)

Re: BBC Parsing

Reply #111

ROFL!
Well, spoiler can be used in signatures. From my experience it's not unusual.
Bugs creator.
Features destroyer.
Template killer.

Re: BBC Parsing

Reply #112

Code: [Select]
		if (!isset($possible['regex_cache']))
{
$possible['regex_cache'] = array();
foreach ($possible[Codes::ATTR_PARAM] as $p => $info) {
// @todo there are 3 options for PARAM_ATTR_QUOTED: required, optional, and none. This doesn't represent that.
$quote = empty($info[Codes::PARAM_ATTR_QUOTED]) ? '' : '"';

// No quotes
if (empty($info[Codes::PARAM_ATTR_QUOTED]) || $info[Codes::PARAM_ATTR_QUOTED] === Codes::NONE)
{
$quote = '';
$end_quote = '';
}
// Quotes are required
elseif ($info[Codes::PARAM_ATTR_QUOTED] === Codes::REQUIRED)
{
$quote = '"';
$end_quote = '"';
}
// Quotes are optional
elseif ($info[Codes::PARAM_ATTR_QUOTED] === Codes::OPTIONAL)
{
// This gets a little tricky. If there was an opening quote, there must be a closing quote.
// If there was no opening quote, there mustn't be a closing quote.
// But, quotes are optional
}

$possible['regex_cache'][] = '(\s+' . $p . '=' . $quote . (isset($info[Codes::PARAM_ATTR_MATCH]) ? $info[Codes::PARAM_ATTR_MATCH] : '(.+?)') . $end_quote. ')' . (empty($info[Codes::PARAM_ATTR_OPTIONAL]) ? '' : '?');
}
$possible['regex_size'] = count($possible['regex_cache']) - 1;
$possible['regex_keys'] = range(0, $possible['regex_size']);
}
I can't think right now because I haven't eaten anything but a bagel today (going to get wings and beer in a minute). This is going to cause me some grief. I think the optional regex is going to require a backref to see if the opening was there.

Re: BBC Parsing

Reply #113

With the autolinking in the preparser, I just realized something. If a tag is add/changed that is a parent of the link, it needs to know that it is in a non-autolinked area. Not sure if I should hardcode this in to the parser or have the parser be able to send the code some way of knowing what tags are open and if it is in an autolink area. I am leaning towards hardcoding it right now and then seeing how I would do it better later.

Re: BBC Parsing

Reply #114

Actually, this is complex. I have to parse the entire message and see if the link is supposed to be an autolink. That means pretty much recreating the parser. I wanted to do the same with the itemcodes.

I think the best way to go about this is to make a mod. It would hook in to see if an autolink was done. It would change the message to add BBC markup at the parse time and would do a query to update the database. Next run wouldn't contain any autolinks/itemcodes for that message. It would still show them as regular uris and itemcodes when editing.

This is a micro-optimization and not really something I care that much about so I'm not going to invest anymore time in to it. Maybe add the hooks now but that's about it.

Re: BBC Parsing

Reply #115

I disabled font, size, email, ftp, iurl, tr, td, table & code into signatures
sorry for my bad english

Re: BBC Parsing

Reply #116

Why iurl and email?

 

Re: BBC Parsing

Reply #117

They can always use url instead of iurl, for the mail I don't want to encourage the conversations by mail, but use the forum instead. Don't know if this is a good idea
sorry for my bad english

Re: BBC Parsing

Reply #118

Quote from: radu81 – They can always use url instead of iurl, for the mail I don't want to encourage the conversations by mail, but use the forum instead. Don't know if this is a good idea
Likely, since emails in siggies can probably be snatched by bots.
~ SimplePortal Support Team ~

Re: BBC Parsing

Reply #119

Started work on submitting this for 1.1. There is one problem - there are a lot of different places where parse_bbc() is used. Controllers are easy because I can just add a method (or a bunch of methods) to the Action controller. It's all of the model/helper/*subs files with functions that make it hard.

There is no DIC variable so containing it somewhere means either adding a generic one or adding a variable for each of the 4 parsers plus codes. I am not a fan of using functions or a class with static methods.

I did a test of Display.controller.php to see if what I copied would work. It does. Here's what I did.

Display.controller.php
Code: [Select]
	public function parseMessageBody($message, $smileys_enabled)
{
global $modSettings, $context;

// If the load average is too high, don't parse the BBC.
if (!empty($modSettings['bbc']) && $modSettings['current_load'] >= $modSettings['bbc'])
{
$context['disabled_parse_bbc'] = true;
return $message;
}

if (empty($modSettings['enableBBC']))
{
if ($smileys_enabled)
{
$smiley_parser = $this->getSmileyParser();
$smiley_parser->parse($message);
}

return $message;
}

$bbc_parser = $this->getBBCParser();
$message = $bbc_parser->parse($message);

if ($smileys_enabled)
{
$smiley_parser = $this->getSmileyParser();
$smiley_parser->parse($message);
}

return $message;
}

Action.controller.php
Code: [Select]
	public function getBBCCodes()
{
global $modSettings;

if ($this->_bbc_codes === null)
{
$disabled = array();

if (!empty($modSettings['disabledBBC']))
{
$temp = explode(',', strtolower($modSettings['disabledBBC']));

foreach ($temp as $tag)
$disabled[trim($tag)] = true;
}

require_once(SUBSDIR . '/BBC/Codes.class.php');
$this->_bbc_codes = new \BBC\Codes(array(), $disabled);
}

return $this->_bbc_codes;
}

public function getBBCParser()
{
if ($this->_bbc_parser === null)
{
require_once(SUBSDIR . '/BBC/BBCParser.class.php');
$this->_bbc_parser = new \BBC\BBCParser($this->getBBCCodes(), $this->getAutolinkParser());
}

return $this->_bbc_parser;
}

public function getAutolinkParser()
{
if ($this->_autolink_parser === null)
{
require_once(SUBSDIR . '/BBC/Autolink.class.php');
$this->_autolink_parser = new \BBC\Autolink($this->getBBCCodes());
}

return $this->_autolink_parser;
}

public function getSmileyParser()
{
if ($this->_smiley_parser === null)
{
require_once(SUBSDIR . '/BBC/SmileyParser.class.php');
$this->_smiley_parser = new \BBC\SmileyParser;
}

return $this->_smiley_parser;
}

public function getHtmlParser()
{
if ($this->_html_parser === null)
{
require_once(SUBSDIR . '/BBC/HtmlParser.class.php');
$this->_html_parser = new \BBC\HtmlParser;
}

return $this->_html_parser;
}

I would prefer to put that in a DIC with a closure so you can change it with ease.