Skip to content

Commit

Permalink
Updated s9e\TextFormatter
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshyPHP committed Nov 14, 2016
1 parent 543c50f commit c39f76d
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 48 deletions.
2 changes: 1 addition & 1 deletion bundle.php

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"type": "phpbb-extension",
"description": "Embed third-party content in your phpBB forum",
"homepage": "https://github.com/s9e/phpbb-ext-mediaembed/",
"version": "20161002",
"version": "20161114",
"keywords": ["phpbb","embed","forum","media"],
"license": "MIT",
"require": {
Expand Down
64 changes: 24 additions & 40 deletions parsing.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ class Parser
protected $cntOpen;
protected $cntTotal;
protected $context;
protected $createdTags;
protected $currentFixingCost;
protected $currentTag;
protected $isRich;
Expand Down Expand Up @@ -69,32 +68,25 @@ public function __wakeup()
{
$this->logger = new Logger;
}
protected function gc()
{
foreach ($this->createdTags as $tag)
$tag->gc();
$this->createdTags = array();
}
protected function reset($text)
{
$text = \preg_replace('/\\r\\n?/', "\n", $text);
$text = \preg_replace('/[\\x00-\\x08\\x0B\\x0C\\x0E-\\x1F]+/S', '', $text);
$this->logger->clear();
$this->cntOpen = array();
$this->cntTotal = array();
$this->createdTags = array();
$this->cntOpen = array();
$this->cntTotal = array();
$this->currentFixingCost = 0;
$this->currentTag = \null;
$this->isRich = \false;
$this->namespaces = array();
$this->openTags = array();
$this->output = '';
$this->pos = 0;
$this->tagStack = array();
$this->tagStackIsSorted = \false;
$this->text = $text;
$this->textLen = \strlen($text);
$this->wsPos = 0;
$this->currentTag = \null;
$this->isRich = \false;
$this->namespaces = array();
$this->openTags = array();
$this->output = '';
$this->pos = 0;
$this->tagStack = array();
$this->tagStackIsSorted = \false;
$this->text = $text;
$this->textLen = \strlen($text);
$this->wsPos = 0;
$this->context = $this->rootContext;
$this->context['inParagraph'] = \false;
++$this->uid;
Expand Down Expand Up @@ -132,7 +124,6 @@ public function parse($text)
$uid = $this->uid;
$this->executePluginParsers();
$this->processTags();
$this->gc();
$this->finalizeOutput();
if ($this->uid !== $uid)
throw new RuntimeException('The parser has been reset during execution');
Expand Down Expand Up @@ -970,7 +961,6 @@ public function addCopyTag(Tag $tag, $pos, $len, $prio = \null)
protected function addTag($type, $name, $pos, $len, $prio)
{
$tag = new Tag($type, $name, $pos, $len, $prio);
$this->createdTags[] = $tag;
if (isset($this->tagsConfig[$name]))
$tag->setFlags($this->tagsConfig[$name]['rules']['flags']);
if (!isset($this->tagsConfig[$name]) && !$tag->isSystemTag())
Expand Down Expand Up @@ -1400,12 +1390,6 @@ public function cascadeInvalidationTo(Tag $tag)
if ($this->invalid)
$tag->invalidate();
}
public function gc()
{
$this->cascade = array();
$this->endTag = \null;
$this->startTag = \null;
}
public function invalidate()
{
if ($this->invalid)
Expand Down Expand Up @@ -1558,10 +1542,10 @@ public function setAttributes(array $attributes)
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
namespace s9e\TextFormatter\Plugins\MediaEmbed;
use s9e\TextFormatter\Utils\Http;
use s9e\TextFormatter\Parser as TagStack;
use s9e\TextFormatter\Parser\Tag;
use s9e\TextFormatter\Plugins\ParserBase;
use s9e\TextFormatter\Utils\Http;
class Parser extends ParserBase
{
protected static $client;
Expand All @@ -1572,13 +1556,13 @@ public function parse($text, array $matches)
$url = $m[0][0];
$pos = $m[0][1];
$len = \strlen($url);
$tag = $this->parser->addSelfClosingTag('MEDIA', $pos, $len, -10);
$tag = $this->parser->addSelfClosingTag($this->config['tagName'], $pos, $len, -10);
$tag->setAttribute('url', $url);
}
}
public static function filterTag(Tag $tag, TagStack $tagStack, array $sites)
{
if ($tag->hasAttribute('media'))
if ($tag->hasAttribute('site'))
self::addTagFromMediaId($tag, $tagStack, $sites);
elseif ($tag->hasAttribute('url'))
self::addTagFromMediaUrl($tag, $tagStack, $sites);
Expand All @@ -1593,13 +1577,13 @@ public static function hasNonDefaultAttribute(Tag $tag)
}
public static function scrape(Tag $tag, array $scrapeConfig, $cacheDir = \null)
{
if (!$tag->hasAttribute('url'))
return \true;
$url = $tag->getAttribute('url');
if (!\preg_match('#^https?://[^<>"\'\\s]+$#D', $url))
return \true;
foreach ($scrapeConfig as $scrape)
self::scrapeEntry($url, $tag, $scrape, $cacheDir);
if ($tag->hasAttribute('url'))
{
$url = $tag->getAttribute('url');
if (\preg_match('#^https?://[^<>"\'\\s]+$#D', $url))
foreach ($scrapeConfig as $scrape)
self::scrapeEntry($url, $tag, $scrape, $cacheDir);
}
return \true;
}
protected static function addSiteTag(Tag $tag, TagStack $tagStack, $siteId)
Expand All @@ -1611,7 +1595,7 @@ protected static function addSiteTag(Tag $tag, TagStack $tagStack, $siteId)
}
protected static function addTagFromMediaId(Tag $tag, TagStack $tagStack, array $sites)
{
$siteId = \strtolower($tag->getAttribute('media'));
$siteId = \strtolower($tag->getAttribute('site'));
if (\in_array($siteId, $sites, \true))
self::addSiteTag($tag, $tagStack, $siteId);
}
Expand Down
8 changes: 4 additions & 4 deletions rendering.php

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion vendor/s9e/TextFormatter
Submodule TextFormatter updated 43 files
+1 −1 composer.json
+1 −1 src/Bundles/Fatdown.php
+1 −1 src/Bundles/Forum.php
+6 −6 src/Bundles/Forum/Renderer.php
+1 −1 src/Bundles/MediaPack.php
+4 −4 src/Bundles/MediaPack/Renderer.php
+94 −9 src/Configurator.php
+2 −0 src/Configurator/Bundles/Fatdown.php
+4 −0 src/Configurator/Bundles/Forum.php
+1 −1 src/Configurator/Bundles/MediaPack.php
+2 −8 src/Configurator/Items/AttributeFilters/AlnumFilter.php
+1 −4 src/Configurator/Items/AttributeFilters/ColorFilter.php
+3 −12 src/Configurator/Items/AttributeFilters/FloatFilter.php
+21 −0 src/Configurator/Items/AttributeFilters/FontfamilyFilter.php
+20 −13 src/Configurator/Items/AttributeFilters/HashmapFilter.php
+2 −8 src/Configurator/Items/AttributeFilters/IdentifierFilter.php
+3 −12 src/Configurator/Items/AttributeFilters/IntFilter.php
+3 −12 src/Configurator/Items/AttributeFilters/NumberFilter.php
+3 −12 src/Configurator/Items/AttributeFilters/RangeFilter.php
+30 −19 src/Configurator/Items/AttributeFilters/RegexpFilter.php
+13 −37 src/Parser.js
+13 −23 src/Parser.php
+0 −12 src/Parser/Tag.js
+0 −6 src/Parser/Tag.php
+37 −6 src/Plugins/BBCodes/Configurator/repository.xml
+3 −3 src/Plugins/Censor/Helper.php
+1 −1 src/Plugins/Emoji/Parser.js
+1 −1 src/Plugins/Emoji/Parser.php
+116 −62 src/Plugins/FancyPants/Parser.js
+68 −35 src/Plugins/FancyPants/Parser.php
+7 −7 src/Plugins/Litedown/Parser.js
+7 −7 src/Plugins/Litedown/Parser.php
+17 −9 src/Plugins/MediaEmbed/Configurator.php
+0 −141 src/Plugins/MediaEmbed/Configurator/CachedSiteDefinitionProvider.php
+131 −0 src/Plugins/MediaEmbed/Configurator/Collections/CachedDefinitionCollection.php
+2 −2 src/Plugins/MediaEmbed/Configurator/Collections/SiteCollection.php
+36 −0 src/Plugins/MediaEmbed/Configurator/Collections/SiteDefinitionCollection.php
+53 −0 src/Plugins/MediaEmbed/Configurator/Collections/XmlFileDefinitionCollection.php
+0 −70 src/Plugins/MediaEmbed/Configurator/LiveSiteDefinitionProvider.php
+0 −34 src/Plugins/MediaEmbed/Configurator/SiteDefinitionProvider.php
+1 −1 src/Plugins/MediaEmbed/Parser.js
+11 −11 src/Plugins/MediaEmbed/Parser.php
+2 −2 src/Plugins/MediaEmbed/Parser/tagFilter.js
2 changes: 1 addition & 1 deletion versions.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"stable":{"20161002":{"current":"20161002","announcement":"https:\/\/www.phpbb.com\/community\/viewtopic.php?f=456&t=2272431","download":"https:\/\/github.com\/s9e\/phpbb-ext-mediaembed\/releases\/download\/20161002\/s9e-mediaembed-20161002.zip","eol":null,"security":false}}}
{"stable":{"20161114":{"current":"20161114","announcement":"https:\/\/www.phpbb.com\/community\/viewtopic.php?f=456&t=2272431","download":"https:\/\/github.com\/s9e\/phpbb-ext-mediaembed\/releases\/download\/20161114\/s9e-mediaembed-20161114.zip","eol":null,"security":false}}}

0 comments on commit c39f76d

Please sign in to comment.