Improved body scanning, increased length
This commit is contained in:
parent
060503eb44
commit
3ce9386cb1
|
@ -69,7 +69,7 @@ class Tag
|
|||
return;
|
||||
}
|
||||
|
||||
$fields = ['name' => substr($name, 0, 64), 'type' => $type];
|
||||
$fields = ['name' => substr($name, 0, 96), 'type' => $type];
|
||||
|
||||
if (!empty($url) && ($url != $name)) {
|
||||
$fields['url'] = strtolower($url);
|
||||
|
@ -119,25 +119,20 @@ class Tag
|
|||
}
|
||||
|
||||
/**
|
||||
* Store tags from the body
|
||||
* Store tags and mentions from the body
|
||||
*
|
||||
* @param integer $uriid
|
||||
* @param string $body
|
||||
* @param integer $uriid URI-Id
|
||||
* @param string $body Body of the post
|
||||
* @param string $tags Accepted tags
|
||||
*/
|
||||
public static function storeFromBody(int $uriid, string $body)
|
||||
public static function storeFromBody(int $uriid, string $body, string $tags = '#@!')
|
||||
{
|
||||
$tags = BBCode::getTags($body);
|
||||
if (empty($tags)) {
|
||||
if (!preg_match_all("/([" . $tags . "])\[url\=(.*?)\](.*?)\[\/url\]/ism", $body, $result, PREG_SET_ORDER)) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($tags as $tag) {
|
||||
if ((substr($tag, 0, 1) != self::TAG_CHARACTER[self::HASHTAG]) || (strlen($tag) <= 1)) {
|
||||
Logger::info('Skip tag', ['uriid' => $uriid, 'tag' => $tag]);
|
||||
continue;
|
||||
}
|
||||
|
||||
self::storeByHash($uriid, '#', $tag);
|
||||
foreach ($result as $tag) {
|
||||
self::storeByHash($uriid, $tag[1], $tag[3], $tag[2]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2410,7 +2410,7 @@ class DFRN
|
|||
|
||||
$item['uri-id'] = ItemURI::insert(['uri' => $item['uri'], 'guid' => $item['guid']]);
|
||||
|
||||
Tag::storeFromBody($item['uri-id'], $item["body"]);
|
||||
Tag::storeFromBody($item['uri-id'], $item["body"], '#');
|
||||
|
||||
// We store the data from "dfrn:diaspora_signature" in a different table, this is done in "Item::insert"
|
||||
$dsprsig = XML::unescape(XML::getFirstNodeValue($xpath, "dfrn:diaspora_signature/text()", $entry));
|
||||
|
|
|
@ -1938,7 +1938,7 @@ class Diaspora
|
|||
$datarray["body"] = self::replacePeopleGuid($body, $person["url"]);
|
||||
|
||||
self::storeMentions($datarray['uri-id'], $text);
|
||||
Tag::storeFromBody($datarray['uri-id'], $datarray["body"]);
|
||||
Tag::storeFromBody($datarray['uri-id'], $datarray["body"], '#');
|
||||
|
||||
self::fetchGuid($datarray);
|
||||
|
||||
|
@ -3013,7 +3013,7 @@ class Diaspora
|
|||
$datarray["body"] = self::replacePeopleGuid($body, $contact["url"]);
|
||||
|
||||
self::storeMentions($datarray['uri-id'], $text);
|
||||
Tag::storeFromBody($datarray['uri-id'], $datarray["body"]);
|
||||
Tag::storeFromBody($datarray['uri-id'], $datarray["body"], '#');
|
||||
|
||||
if ($provider_display_name != "") {
|
||||
$datarray["app"] = $provider_display_name;
|
||||
|
|
|
@ -1297,7 +1297,7 @@ return [
|
|||
"fields" => [
|
||||
"id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
|
||||
"type" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
|
||||
"name" => ["type" => "varchar(64)", "not null" => "1", "default" => "", "comment" => ""],
|
||||
"name" => ["type" => "varchar(96)", "not null" => "1", "default" => "", "comment" => ""],
|
||||
"url" => ["type" => "varbinary(255)", "not null" => "1", "default" => "", "comment" => ""]
|
||||
],
|
||||
"indexes" => [
|
||||
|
|
Loading…
Reference in New Issue
Block a user