Skip to content

Commit 40aaf6f

Browse files
committed
Correction of protocol and file extension handling
Previously the original command arguments may have been modified in a way that would result in errors for the receviing application.
1 parent b755271 commit 40aaf6f

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

src/com/inet/gradle/setup/msi/WxsFileBuilder.java

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,17 @@ private void registerSchemeDefinition( ProtocolHandler handler ) {
219219

220220
Element registrySubKey = addRegistryKey( registryEntries, "HKCR", id( scheme + "_protocol_handler_shell" ), scheme + "\\shell\\open\\command" );
221221

222-
handler.setStartArguments( handler.getStartArguments() + " \"%1\"" );
222+
// multiplied the actual command
223+
// handler.setStartArguments( handler.getStartArguments() + " \"%1\"" );
223224
CommandLine cmd = new CommandLine( handler, javaDir );
224-
addRegistryValue( registrySubKey, null, "string", cmd.full );
225+
226+
// add the file parameter if not in the command already
227+
String fullCommand = cmd.full;
228+
if ( !fullCommand.contains( "%1" ) ) {
229+
fullCommand += " \"%1\"";
230+
}
231+
232+
addRegistryValue( registrySubKey, null, "string", fullCommand );
225233
}
226234
}
227235

@@ -941,7 +949,14 @@ private void registerFileExtension( DesktopStarter starter, CommandLine cmd ) th
941949
}
942950
String[] segments = segments( targetFile );
943951
addAttributeIfNotExists( verb, "TargetFile", id( segments, segments.length ) );
944-
addAttributeIfNotExists( verb, "Argument", cmd.arguments + "\"%1\"" );
952+
953+
// add the file parameter if not in the command already
954+
String arguments = cmd.arguments;
955+
if ( !arguments.contains( "%1" ) ) {
956+
arguments += " \"%1\"";
957+
}
958+
959+
addAttributeIfNotExists( verb, "Argument", arguments );
945960
}
946961
}
947962
}

0 commit comments

Comments
 (0)