mirror of
https://github.com/koel/koel
synced 2024-11-10 06:34:14 +00:00
html_entity_decode() tags, fixes #323
This commit is contained in:
parent
f8c7233cd9
commit
68baf5001c
2 changed files with 31 additions and 4 deletions
|
@ -139,10 +139,11 @@ class File
|
|||
$lyrics = array_get($comments, 'unsynchronised_lyric', [''])[0];
|
||||
}
|
||||
|
||||
$props['artist'] = trim($artist);
|
||||
$props['album'] = trim($album);
|
||||
$props['title'] = trim($title);
|
||||
$props['lyrics'] = trim($lyrics);
|
||||
// Fixes #323, where tag names can be htmlentities()'ed
|
||||
$props['artist'] = html_entity_decode(trim($artist));
|
||||
$props['album'] = html_entity_decode(trim($album));
|
||||
$props['title'] = html_entity_decode(trim($title));
|
||||
$props['lyrics'] = html_entity_decode(trim($lyrics));
|
||||
|
||||
return $this->info = $props;
|
||||
}
|
||||
|
|
|
@ -3,10 +3,12 @@
|
|||
use App\Events\LibraryChanged;
|
||||
use App\Libraries\WatchRecord\InotifyWatchRecord;
|
||||
use App\Models\Album;
|
||||
use App\Models\File;
|
||||
use App\Models\Song;
|
||||
use App\Services\Media;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
||||
use Mockery as m;
|
||||
|
||||
class MediaTest extends TestCase
|
||||
{
|
||||
|
@ -157,4 +159,28 @@ class MediaTest extends TestCase
|
|||
$this->notSeeInDatabase('songs', ['path' => $this->mediaPath.'/subdir/no-name.MP3']);
|
||||
$this->notSeeInDatabase('songs', ['path' => $this->mediaPath.'/subdir/back-in-black.mp3']);
|
||||
}
|
||||
|
||||
public function testHtmlEntitiesInTags()
|
||||
{
|
||||
$getID3 = m::mock(getID3::class, [
|
||||
'analyze' => [
|
||||
'tags' => [
|
||||
'id3v2' => [
|
||||
'title' => ['水谷広実'],
|
||||
'album' => ['小岩井こ Random'],
|
||||
'artist' => ['佐倉綾音 Unknown'],
|
||||
],
|
||||
],
|
||||
'encoding' => 'UTF-8',
|
||||
'playtime_seconds' => 100,
|
||||
],
|
||||
]);
|
||||
|
||||
$file = new File(dirname(__FILE__).'/songs/blank.mp3', $getID3);
|
||||
$info = $file->getInfo();
|
||||
|
||||
$this->assertEquals('佐倉綾音 Unknown', $info['artist']);
|
||||
$this->assertEquals('小岩井こ Random', $info['album']);
|
||||
$this->assertEquals('水谷広実', $info['title']);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue