summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrbuj <[email protected]>2019-08-29 23:42:40 +0200
committerrbuj <[email protected]>2019-09-02 20:37:42 +0200
commit0eebca9c9bbcc6e8d4715a3cd8dbf321884dccae (patch)
tree1dcf25761ef7fc533fc618fe1092f87baa9d6fc2 /src
parentdf3d24ca21ce8abd0f325c21dc7e249803e2ab83 (diff)
downloadengrampa-0eebca9c9bbcc6e8d4715a3cd8dbf321884dccae.tar.bz2
engrampa-0eebca9c9bbcc6e8d4715a3cd8dbf321884dccae.tar.xz
java-utils: Remove blank spaces before reading package name
Closes https://github.com/mate-desktop/engrampa/issues/291 Test: touch test.txt zip test.zip test.txt mv test.zip test.jar cat << EOF > HelloWorld.java package org.mate.tests; class HelloWorld { public static void main(String args[]) { System.out.println("Hello, World"); } } EOF engrampa -a test.jar HelloWorld.java jar tf test.jar Output: test.txt org/mate/tests/HelloWorld.java
Diffstat (limited to 'src')
-rw-r--r--src/java-utils.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/java-utils.c b/src/java-utils.c
index 573174f..8693aaa 100644
--- a/src/java-utils.c
+++ b/src/java-utils.c
@@ -24,6 +24,7 @@
#include <unistd.h>
#include <errno.h>
#include <string.h>
+#include <ctype.h>
#include <glib.h>
#include "java-utils.h"
@@ -423,13 +424,23 @@ get_package_name_from_java_file (char *fname)
int index = 0;
while (read (cfile->fd, &ch, 1) == 1) {
+ if ((ch != ' ') && (ch != '\t'))
+ break;
+ }
+ do {
if (ch == ';')
break;
- if (ch == '.')
+ if (ch == '.') {
buffer[index++] = '/';
- else
+ } else if (isalnum (ch) != 0) {
buffer[index++] = ch;
- }
+ } else if ((ch == '_') || (ch == '$')) {
+ buffer[index++] = ch;
+ } else {
+ index = 0;
+ break;
+ }
+ } while (read (cfile->fd, &ch, 1) == 1);
buffer[index] = 0;
package = g_strdup (buffer);
}