xarchiver icon indicating copy to clipboard operation
xarchiver copied to clipboard

Fix bug with handling of non-Unix lha archives

Open fragglet opened this issue 6 months ago • 1 comments

The only lha archives that have UID/GID metadata are those generated by the Unix version of lha. Archives from other systems just show empty whitespace at this point in the list output. As a result, trying to open such archives with xarchiver just produced an empty window. This detects when there is whitespace in the UID/GID column and handles it appropriately.

fragglet avatar Jun 12 '25 20:06 fragglet

This PR makes most .lzh archives in the lhasa test suite open correctly; the two exceptions are:

  • Mac OS archives have "[Mac OS]" listed in the permissions column, and this gets split as "[Mac" in the permissions column and "OS]" in the UID/GID column
  • ~~The UnLHA archive listing fails to parse, possibly because -lhx- isn't recognized as a compression method.~~ -- Fix for this is now in #215.

fragglet avatar Jun 12 '25 20:06 fragglet

I have expanded this PR to fix a similar parsing bug when the timestamp field is empty. PR title and description have been updated accordingly.

fragglet avatar Jun 13 '25 18:06 fragglet

@ib - any chance you can review my change?

fragglet avatar Jun 23 '25 19:06 fragglet

Let's talk about about "lha: Fix handling of non-Unix lha archives" first.

The commit message describes the problem and the patch very well, but please drop the "lha:" prefix. We don't use such prefixes.

Patch source comments to follow.

ib avatar Jul 07 '25 10:07 ib

Now "lha: Fix handling of missing timestamp field":

Do not refer to another bug. Describe the commit as you did in "lha: Fix handling of non-Unix lha archives".

EDIT: Instead of the "lha:" prefix: "Fix handling of missing timestamp field in lha archives"

ib avatar Jul 07 '25 12:07 ib

Mac OS archives have "[Mac OS]" listed in the permissions column, and this gets split as "[Mac" in the permissions column and "OS]" in the UID/GID column

I'll fix this after your pull requests:

--- a/src/lha.c
+++ b/src/lha.c
@@ -69,7 +69,7 @@ static void xa_lha_parse_output (gchar *line, XArchive *archive)
 {
 	XEntry *entry;
 	gpointer item[7];
-	gchar *filename, time[6];
+	gchar *filename, permissions[11], time[6];
 	gboolean dir, link;
 
 	USE_PARSER;
@@ -94,12 +94,16 @@ static void xa_lha_parse_output (gchar *line, XArchive *archive)
 		return;
 	}
 
-	/* permissions */
-	NEXT_ITEM(item[5]);
+	/* permissions (may contain spaces) */
+
+	item[5] = strncpy(permissions, line, sizeof(permissions));
+	permissions[sizeof(permissions) -1] = 0;
 
 	dir = (*(char *) item[5] == 'd');
 	link = (*(char *) item[5] == 'l');
 
+	LINE_SKIP(sizeof(permissions));
+
 	/* uid/gid */
 	NEXT_ITEM(item[6]);
 

ib avatar Jul 07 '25 14:07 ib

Are you going to revise your pull request?

ib avatar Jul 17 '25 09:07 ib

Are you going to revise your pull request?

Sorry I've been quite busy lately as I recently started a new job, I'll try to find the time to get around to addressing your comments when I can.

fragglet avatar Jul 25 '25 12:07 fragglet

Sorry I've been quite busy lately

No problem! It might be easier if I fix it.

ib avatar Jul 25 '25 19:07 ib

Fixed.

ib avatar Aug 01 '25 12:08 ib

Thanks!

fragglet avatar Aug 04 '25 14:08 fragglet