[multimedia/k3b/release/26.08] /: Fix import of sessions with a Joliet descriptor
Albert Astals Cid <[email protected]>
| Newsgroups | gmane.comp.kde.cvs |
|---|---|
| Message-ID | <[email protected]> |
Git commit 7f26f89147da7aee67be42b120ec3b863ca1882e by Albert Astals Cid, on behalf of Ole Osterhagen.
Committed on 08/08/2026 at 21:43.
Pushed by aacid into branch 'release/26.08'.
Fix import of sessions with a Joliet descriptor
In a session which uses the Joliet extension, directory entries have
to be distinguished if they belong to the Joliet supplementary volume
descriptor or not. Only the entries from the Joliet descriptor use UCS-2
for file or directory identifiers.
BUG: 349865
(cherry picked from commit 3a539364ff286b2f5a0769c45458afb9f96efffc)
M +7 -1 libk3b/tools/k3biso9660.cpp
M +7 -0 libk3b/tools/k3biso9660.h
M +6 -0 tests/CMakeLists.txt
A +84 -0 tests/k3biso9660test.cpp *
A +15 -0 tests/k3biso9660test.h *
A +- -- tests/testdata/iso.iso
A +- -- tests/testdata/joliet.iso
A +- -- tests/testdata/rockridge.iso
A +- -- tests/testdata/rockridge_joliet.iso
The files marked with a * at the end have a non valid license. Please read: https://community.kde.org/Policies/Licensing_Policy and use the headers which are listed at that page.
https://invent.kde.org/multimedia/k3b/-/commit/7f26f89147da7aee67be42b120ec3b863ca1882e
diff --git a/libk3b/tools/k3biso9660.cpp b/libk3b/tools/k3biso9660.cpp
index ecc85e994..4a3e74610 100644
--- a/libk3b/tools/k3biso9660.cpp
+++ b/libk3b/tools/k3biso9660.cpp
@@ -91,7 +91,7 @@ int K3b::Iso9660::isofs_callback( struct iso_directory_record *idr, void *udata
group=iso->dirent->group();
if (idr->flags[0] & 2) access |= S_IFDIR; else access |= S_IFREG;
if (!special) {
- if( !iso->plainIso9660() && iso->jolietLevel() ) {
+ if( !iso->plainIso9660() && iso->isDirentFromJoliet() ) {
for (i=0;i<(isonum_711(idr->name_len)-1);i+=2) {
QChar ch( be2me_16(*reinterpret_cast<ushort *>(&(idr->name[i]))) );
if (ch==';') break;
@@ -865,6 +865,12 @@ void K3b::Iso9660::debugEntry( const K3b::Iso9660Entry* entry, int depth ) const
}
+bool K3b::Iso9660::isDirentFromJoliet() const
+{
+ return d->jolietDirs.contains( dirent );
+}
+
+
K3b::Iso9660SimplePrimaryDescriptor::Iso9660SimplePrimaryDescriptor()
: volumeSetSize(0),
volumeSetNumber(0),
diff --git a/libk3b/tools/k3biso9660.h b/libk3b/tools/k3biso9660.h
index ad69f5683..c48e5c812 100644
--- a/libk3b/tools/k3biso9660.h
+++ b/libk3b/tools/k3biso9660.h
@@ -423,6 +423,13 @@ namespace K3b {
void debugEntry( const Iso9660Entry*, int depth ) const;
+ /**
+ * @returns true if the current directory entry is part of a
+ * Joliet supplementary volume descriptor
+ * false otherwise
+ */
+ bool isDirentFromJoliet() const;
+
int m_joliet;
// only used for creation
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 793eacecb..8fa65acc1 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -62,6 +62,12 @@ target_link_libraries(k3bdefaultexternalprogramstest
k3blib)
add_test(NAME k3bdefaultexternalprogramstest COMMAND k3bdefaultexternalprogramstest)
+add_executable(k3biso9660test k3biso9660test.cpp)
+target_link_libraries(k3biso9660test
+ Qt6::Test
+ k3blib)
+add_test(NAME k3biso9660test COMMAND k3biso9660test)
+
qt_generate_dbus_interface(${CMAKE_SOURCE_DIR}/src/k3bjobinterface.h org.k3b.Job.xml)
qt_add_dbus_adaptor(dbus_sources ${CMAKE_CURRENT_BINARY_DIR}/org.k3b.Job.xml ${CMAKE_SOURCE_DIR}/src/k3bjobinterface.h K3b::JobInterface k3bjobinterfaceadaptor K3bJobInterfaceAdaptor)
diff --git a/tests/k3biso9660test.cpp b/tests/k3biso9660test.cpp
new file mode 100644
index 000000000..b41d40b58
--- /dev/null
+++ b/tests/k3biso9660test.cpp
@@ -0,0 +1,84 @@
+#include "k3biso9660test.h"
+#include "k3biso9660.h"
+
+#include <QTest>
+
+QTEST_APPLESS_MAIN( Iso9660Test )
+
+namespace {
+ void verifyDirectoryEntry( const K3b::Iso9660Directory* dirEntry, const QString& expected )
+ {
+ if ( expected.isEmpty() ) {
+ QVERIFY( !dirEntry );
+ } else {
+ QVERIFY( dirEntry );
+ QVERIFY( dirEntry->entry(expected) );
+ }
+ }
+} // namespace
+
+void Iso9660Test::testEntries_data()
+{
+ // rockridge_joliet.iso
+ // touch ¹²³.txt && genisoimage -graft-points -no-pad -rock -joliet -o rockridge_joliet.iso äöüß/=¹²³.txt && rm ¹²³.txt
+
+ // rockridge.iso
+ // touch ¹²³.txt && genisoimage -graft-points -no-pad -rock -o rockridge.iso äöüß/=¹²³.txt && rm ¹²³.txt
+
+ // joliet.iso
+ // touch ¹²³.txt && genisoimage -graft-points -no-pad -joliet -o joliet.iso äöüß/=¹²³.txt && rm ¹²³.txt
+
+ // iso.iso
+ // touch ¹²³.txt && genisoimage -graft-points -no-pad -o iso.iso äöüß/=¹²³.txt && rm ¹²³.txt
+
+ QTest::addColumn<QString>( "filename" );
+ QTest::addColumn<bool >( "plainIso" );
+ QTest::addColumn<QString>( "rr" );
+ QTest::addColumn<QString>( "joliet" );
+ QTest::addColumn<QString>( "iso" );
+
+ QTest::newRow( "Rockridge/Joliet, !plainIso" )
+ << "rockridge_joliet.iso" << false
+ << "äöüß/¹²³.txt" << "äöüß/¹²³.txt" << "äöüß/¹²³.txt";
+ QTest::newRow( "Rockridge, !plainIso" )
+ << "rockridge.iso" << false
+ << "äöüß/¹²³.txt" << "" << "äöüß/¹²³.txt";
+ QTest::newRow( "Joliet, !plainIso" )
+ << "joliet.iso" << false
+ << "" << "äöüß/¹²³.txt" << "________/______.TXT";
+ QTest::newRow( "Iso, !plainIso" )
+ << "iso.iso" << false
+ << "" << "" << "________/______.TXT";
+
+ QTest::newRow( "Rockridge/Joliet, plainIso" )
+ << "rockridge_joliet.iso" << true
+ << "" << "" << "________/______.TXT";
+ QTest::newRow( "Rockridge, plainIso" )
+ << "rockridge.iso" << true
+ << "" << "" << "________/______.TXT";
+ QTest::newRow( "Joliet, plainIso" )
+ << "joliet.iso" << true
+ << "" << "" << "________/______.TXT";
+ QTest::newRow( "Iso, plainIso" )
+ << "iso.iso" << true
+ << "" << "" << "________/______.TXT";
+}
+
+void Iso9660Test::testEntries()
+{
+ QFETCH( QString, filename );
+ QFETCH( bool, plainIso );
+ QFETCH( QString, rr );
+ QFETCH( QString, joliet );
+ QFETCH( QString, iso );
+
+ K3b::Iso9660 isoImage( QFINDTESTDATA( "testdata/" + filename ) );
+ isoImage.setPlainIso9660( plainIso );
+ QVERIFY( isoImage.open() );
+
+ verifyDirectoryEntry( isoImage.firstRRDirEntry(), rr );
+ verifyDirectoryEntry( isoImage.firstJolietDirEntry(), joliet );
+ verifyDirectoryEntry( isoImage.firstIsoDirEntry(), iso );
+}
+
+#include "moc_k3biso9660test.cpp"
diff --git a/tests/k3biso9660test.h b/tests/k3biso9660test.h
new file mode 100644
index 000000000..a5c785c1f
--- /dev/null
+++ b/tests/k3biso9660test.h
@@ -0,0 +1,15 @@
+#ifndef K3B_ISO_9660_TEST_H
+#define K3B_ISO_9660_TEST_H
+
+#include <QObject>
+
+class Iso9660Test : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void testEntries_data();
+ void testEntries();
+};
+
+#endif // K3B_ISO_9660_TEST_H
diff --git a/tests/testdata/iso.iso b/tests/testdata/iso.iso
new file mode 100644
index 000000000..3658d1729
Binary files /dev/null and b/tests/testdata/iso.iso differ
diff --git a/tests/testdata/joliet.iso b/tests/testdata/joliet.iso
new file mode 100644
index 000000000..8e5682eaa
Binary files /dev/null and b/tests/testdata/joliet.iso differ
diff --git a/tests/testdata/rockridge.iso b/tests/testdata/rockridge.iso
new file mode 100644
index 000000000..197ab2d68
Binary files /dev/null and b/tests/testdata/rockridge.iso differ
diff --git a/tests/testdata/rockridge_joliet.iso b/tests/testdata/rockridge_joliet.iso
new file mode 100644
index 000000000..6c6ab6fd4
Binary files /dev/null and b/tests/testdata/rockridge_joliet.iso differ