mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 23:45:10 +00:00
Stop escaping notes, move to parser.
This commit is contained in:
@@ -41,8 +41,7 @@ use Symfony\Component\HttpFoundation\ParameterBag;
|
|||||||
*/
|
*/
|
||||||
class ShowController extends Controller
|
class ShowController extends Controller
|
||||||
{
|
{
|
||||||
/** @var TransactionGroupRepositoryInterface */
|
private TransactionGroupRepositoryInterface $repository;
|
||||||
private $repository;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ShowController constructor.
|
* ShowController constructor.
|
||||||
@@ -103,12 +102,7 @@ class ShowController extends Controller
|
|||||||
$amounts = $this->getAmounts($groupArray);
|
$amounts = $this->getAmounts($groupArray);
|
||||||
$accounts = $this->getAccounts($groupArray);
|
$accounts = $this->getAccounts($groupArray);
|
||||||
|
|
||||||
// make sure notes are escaped but not double escaped.
|
|
||||||
foreach ($groupArray['transactions'] as $index => $transaction) {
|
foreach ($groupArray['transactions'] as $index => $transaction) {
|
||||||
$search = ['&', '>', '<'];
|
|
||||||
if (!Str::contains($transaction['notes'], $search)) {
|
|
||||||
$groupArray['transactions'][$index]['notes'] = e($transaction['notes']);
|
|
||||||
}
|
|
||||||
$groupArray['transactions'][$index]['tags'] = $this->repository->getTagObjects($groupArray['transactions'][$index]['transaction_journal_id']);
|
$groupArray['transactions'][$index]['tags'] = $this->repository->getTagObjects($groupArray['transactions'][$index]['transaction_journal_id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -63,6 +63,7 @@ use Illuminate\Database\Query\Builder;
|
|||||||
class Note extends Model
|
class Note extends Model
|
||||||
{
|
{
|
||||||
use SoftDeletes;
|
use SoftDeletes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The attributes that should be casted to native types.
|
* The attributes that should be casted to native types.
|
||||||
*
|
*
|
||||||
@@ -77,16 +78,6 @@ class Note extends Model
|
|||||||
/** @var array Fields that can be filled */
|
/** @var array Fields that can be filled */
|
||||||
protected $fillable = ['title', 'text', 'noteable_id', 'noteable_type'];
|
protected $fillable = ['title', 'text', 'noteable_id', 'noteable_type'];
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string|null $value
|
|
||||||
*
|
|
||||||
* @return string|null
|
|
||||||
*/
|
|
||||||
public function getTextAttribute(?string $value): ?string
|
|
||||||
{
|
|
||||||
return null === $value ? null : htmlspecialchars_decode($value, ENT_QUOTES);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @codeCoverageIgnore
|
* @codeCoverageIgnore
|
||||||
*
|
*
|
||||||
@@ -96,14 +87,4 @@ class Note extends Model
|
|||||||
{
|
{
|
||||||
return $this->morphTo();
|
return $this->morphTo();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param $value
|
|
||||||
*
|
|
||||||
* @codeCoverageIgnore
|
|
||||||
*/
|
|
||||||
public function setTextAttribute(string $value): void
|
|
||||||
{
|
|
||||||
$this->attributes['text'] = e($value);
|
|
||||||
}
|
|
||||||
}
|
}
|
@@ -28,6 +28,8 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
|||||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||||
use FireflyIII\Support\Search\OperatorQuerySearch;
|
use FireflyIII\Support\Search\OperatorQuerySearch;
|
||||||
use League\CommonMark\CommonMarkConverter;
|
use League\CommonMark\CommonMarkConverter;
|
||||||
|
use League\CommonMark\Environment;
|
||||||
|
use League\CommonMark\Extension\GithubFlavoredMarkdownExtension;
|
||||||
use Route;
|
use Route;
|
||||||
use Twig\Extension\AbstractExtension;
|
use Twig\Extension\AbstractExtension;
|
||||||
use Twig\TwigFilter;
|
use Twig\TwigFilter;
|
||||||
@@ -285,8 +287,10 @@ class General extends AbstractExtension
|
|||||||
return new TwigFilter(
|
return new TwigFilter(
|
||||||
'markdown',
|
'markdown',
|
||||||
static function (string $text): string {
|
static function (string $text): string {
|
||||||
$converter = new CommonMarkConverter;
|
$environment = Environment::createCommonMarkEnvironment();
|
||||||
|
$environment->addExtension(new GithubFlavoredMarkdownExtension());
|
||||||
|
|
||||||
|
$converter = new CommonMarkConverter([], $environment);
|
||||||
return $converter->convertToHtml($text);
|
return $converter->convertToHtml($text);
|
||||||
}, ['is_safe' => ['html']]
|
}, ['is_safe' => ['html']]
|
||||||
);
|
);
|
||||||
|
Reference in New Issue
Block a user