- list($mp3gain_undo_left, $mp3gain_undo_right, $mp3gain_undo_wrap) = explode(',', $thisfile_ape_items_current['data'][0]);
- $thisfile_replaygain['mp3gain']['undo_left'] = intval($mp3gain_undo_left);
- $thisfile_replaygain['mp3gain']['undo_right'] = intval($mp3gain_undo_right);
- $thisfile_replaygain['mp3gain']['undo_wrap'] = (($mp3gain_undo_wrap == 'Y') ? true : false);
+ if (preg_match('#^[\\-\\+][0-9]{3},[\\-\\+][0-9]{3},[NW]$#', $thisfile_ape_items_current['data'][0])) {
+ list($mp3gain_undo_left, $mp3gain_undo_right, $mp3gain_undo_wrap) = explode(',', $thisfile_ape_items_current['data'][0]);
+ $thisfile_replaygain['mp3gain']['undo_left'] = intval($mp3gain_undo_left);
+ $thisfile_replaygain['mp3gain']['undo_right'] = intval($mp3gain_undo_right);
+ $thisfile_replaygain['mp3gain']['undo_wrap'] = (($mp3gain_undo_wrap == 'Y') ? true : false);
+ } else {
+ $info['warning'][] = 'MP3gainUndo value in APEtag appears invalid: "'.$thisfile_ape_items_current['data'][0].'"';
+ }