Correct processing of headerless CD-Text coming from images, in image info command. Fixes #662

This commit is contained in:
2026-01-14 16:26:59 +00:00
parent 0bec394166
commit 7343de9558
5 changed files with 26 additions and 30 deletions

View File

@@ -1,8 +1,8 @@
<component name="ProjectRunConfigurationManager"> <component name="ProjectRunConfigurationManager">
<configuration default="false" name="Aaru" type="DotNetProject" factoryName=".NET Project"> <configuration default="false" name="Aaru" type="DotNetProject" factoryName=".NET Project">
<option name="EXE_PATH" value="$PROJECT_DIR$/Aaru/bin/Release/net10.0/linux-x64/aaru" /> <option name="EXE_PATH" value="$PROJECT_DIR$/Aaru/bin/Debug/net10.0/osx-arm64/aaru" />
<option name="PROGRAM_PARAMETERS" value="i create-sidecar &quot;OpenSolaris Disc 1 (708-0235-11).aif&quot;" /> <option name="PROGRAM_PARAMETERS" value="i info &quot;Tanxugueiras - Contra (CLVR012).aif&quot;" />
<option name="WORKING_DIRECTORY" value="/mnt/datos/Dumps (bugs)/PC/Operating Systems/OpenSolaris Starter Kit (819-7180-10) (July 2006)/" /> <option name="WORKING_DIRECTORY" value="/Volumes/iPhone/issue662/" />
<option name="PASS_PARENT_ENVS" value="1" /> <option name="PASS_PARENT_ENVS" value="1" />
<option name="ENV_FILE_PATHS" value="" /> <option name="ENV_FILE_PATHS" value="" />
<option name="REDIRECT_INPUT_PATH" value="" /> <option name="REDIRECT_INPUT_PATH" value="" />

View File

@@ -49,6 +49,7 @@ using Aaru.Decoders.SCSI;
using Aaru.Devices; using Aaru.Devices;
using Aaru.Localization; using Aaru.Localization;
using Aaru.Logging; using Aaru.Logging;
using Humanizer;
using Track = Aaru.CommonTypes.Structs.Track; using Track = Aaru.CommonTypes.Structs.Track;
using TrackType = Aaru.CommonTypes.Enums.TrackType; using TrackType = Aaru.CommonTypes.Enums.TrackType;

View File

@@ -509,16 +509,14 @@ public static class ImageInfo
if(errno == ErrorNumber.NoError) if(errno == ErrorNumber.NoError)
{ {
uint dataLen = Swapping.Swap(BitConverter.ToUInt32(cdtext, 0)); ushort dataLen = Swapping.Swap(BitConverter.ToUInt16(cdtext, 0));
if(dataLen + 4 != cdtext.Length) if(dataLen + 2 != cdtext.Length)
{ {
var tmp = new byte[cdtext.Length + 4]; var tmp = new byte[cdtext.Length + 4];
Array.Copy(cdtext, 0, tmp, 4, cdtext.Length); Array.Copy(cdtext, 0, tmp, 4, cdtext.Length);
tmp[0] = (byte)((cdtext.Length & 0xFF000000) >> 24); tmp[0] = (byte)((cdtext.Length + 2 & 0xFF00) >> 8);
tmp[1] = (byte)((cdtext.Length & 0xFF0000) >> 16); tmp[1] = (byte)(cdtext.Length + 2 & 0xFF);
tmp[2] = (byte)((cdtext.Length & 0xFF00) >> 8);
tmp[3] = (byte)(cdtext.Length & 0xFF);
cdtext = tmp; cdtext = tmp;
} }
@@ -868,7 +866,9 @@ public static class ImageInfo
} }
} }
if(imageFormat is IFluxImage fluxImage && fluxImage.GetAllFluxCaptures(out List<FluxCapture> captures) == ErrorNumber.NoError && captures is { Count: > 0 }) if(imageFormat is IFluxImage fluxImage &&
fluxImage.GetAllFluxCaptures(out List<FluxCapture> captures) == ErrorNumber.NoError &&
captures is { Count: > 0 })
AaruLogging.WriteLine(Localization.Core.Image_flux_captures); AaruLogging.WriteLine(Localization.Core.Image_flux_captures);
if(imageFormat is not IOpticalMediaImage opticalImage) return; if(imageFormat is not IOpticalMediaImage opticalImage) return;

View File

@@ -274,8 +274,9 @@ public sealed class ImageInfoViewModel : ViewModelBase
} }
if(imageFormat.Info.ReadableMediaTags is { Count: > 0 }) if(imageFormat.Info.ReadableMediaTags is { Count: > 0 })
foreach(MediaTagType tag in imageFormat.Info.ReadableMediaTags.Order()) {
MediaTagsList.Add(tag.Humanize()); foreach(MediaTagType tag in imageFormat.Info.ReadableMediaTags.Order()) MediaTagsList.Add(tag.Humanize());
}
if(imageFormat.Info.ReadableSectorTags is { Count: > 0 }) if(imageFormat.Info.ReadableSectorTags is { Count: > 0 })
{ {
@@ -456,16 +457,14 @@ public sealed class ImageInfoViewModel : ViewModelBase
if(errno == ErrorNumber.NoError) if(errno == ErrorNumber.NoError)
{ {
uint dataLen = Swapping.Swap(BitConverter.ToUInt32(cdtext, 0)); ushort dataLen = Swapping.Swap(BitConverter.ToUInt16(cdtext, 0));
if(dataLen + 4 != cdtext.Length) if(dataLen + 2 != cdtext.Length)
{ {
var tmp = new byte[cdtext.Length + 4]; var tmp = new byte[cdtext.Length + 4];
Array.Copy(cdtext, 0, tmp, 4, cdtext.Length); Array.Copy(cdtext, 0, tmp, 4, cdtext.Length);
tmp[0] = (byte)((cdtext.Length & 0xFF000000) >> 24); tmp[0] = (byte)((cdtext.Length + 2 & 0xFF00) >> 8);
tmp[1] = (byte)((cdtext.Length & 0xFF0000) >> 16); tmp[1] = (byte)(cdtext.Length + 2 & 0xFF);
tmp[2] = (byte)((cdtext.Length & 0xFF00) >> 8);
tmp[3] = (byte)(cdtext.Length & 0xFF);
cdtext = tmp; cdtext = tmp;
} }
@@ -794,9 +793,8 @@ public sealed class ImageInfoViewModel : ViewModelBase
try try
{ {
if(opticalMediaImage.Sessions is { Count: > 0 }) if(opticalMediaImage.Sessions is { Count: > 0 })
{ foreach(Session session in opticalMediaImage.Sessions)
foreach(Session session in opticalMediaImage.Sessions) Sessions.Add(session); Sessions.Add(session);
}
} }
catch(Exception ex) catch(Exception ex)
{ {
@@ -806,9 +804,8 @@ public sealed class ImageInfoViewModel : ViewModelBase
try try
{ {
if(opticalMediaImage.Tracks is { Count: > 0 }) if(opticalMediaImage.Tracks is { Count: > 0 })
{ foreach(Track track in opticalMediaImage.Tracks)
foreach(Track track in opticalMediaImage.Tracks) Tracks.Add(track); Tracks.Add(track);
}
} }
catch(Exception ex) catch(Exception ex)
{ {
@@ -820,7 +817,7 @@ public sealed class ImageInfoViewModel : ViewModelBase
if(imageFormat is IFluxImage fluxImage) if(imageFormat is IFluxImage fluxImage)
{ {
ErrorNumber fluxError = fluxImage.GetAllFluxCaptures(out List<FluxCapture> fluxCaptures); ErrorNumber fluxError = fluxImage.GetAllFluxCaptures(out List<FluxCapture> fluxCaptures);
if(fluxError == ErrorNumber.NoError && fluxCaptures is { Count: > 0 }) if(fluxError == ErrorNumber.NoError && fluxCaptures is { Count: > 0 })
{ {
FluxInfo = new FluxInfo FluxInfo = new FluxInfo

View File

@@ -189,14 +189,12 @@ public sealed partial class DecodeMediaTagsViewModel : ViewModelBase
case MediaTagType.CD_TEXT: case MediaTagType.CD_TEXT:
dataLen = Swapping.Swap(BitConverter.ToUInt32(value.Data, 0)); dataLen = Swapping.Swap(BitConverter.ToUInt32(value.Data, 0));
if(dataLen + 4 != value.Data.Length) if(dataLen + 2 != value.Data.Length)
{ {
var tmp = new byte[value.Data.Length + 4]; var tmp = new byte[value.Data.Length + 4];
Array.Copy(value.Data, 0, tmp, 4, value.Data.Length); Array.Copy(value.Data, 0, tmp, 4, value.Data.Length);
tmp[0] = (byte)((value.Data.Length & 0xFF000000) >> 24); tmp[0] = (byte)((value.Data.Length + 2 & 0xFF00) >> 8);
tmp[1] = (byte)((value.Data.Length & 0xFF0000) >> 16); tmp[1] = (byte)(value.Data.Length + 2 & 0xFF);
tmp[2] = (byte)((value.Data.Length & 0xFF00) >> 8);
tmp[3] = (byte)(value.Data.Length & 0xFF);
value.Data = tmp; value.Data = tmp;
} }