diff options
author | Reinier Zwitserloot <r.zwitserloot@projectlombok.org> | 2021-09-15 15:57:36 +0200 |
---|---|---|
committer | Reinier Zwitserloot <r.zwitserloot@projectlombok.org> | 2021-09-15 15:57:36 +0200 |
commit | 0d7260d0525d68007635df717b2f5520794afbb5 (patch) | |
tree | 655f90c456ecafe78cab1fd16223e8f75f61e555 /src/installer/lombok | |
parent | 69c928a629ee66daa175c2eb05d4bbc118cf019c (diff) | |
download | lombok-0d7260d0525d68007635df717b2f5520794afbb5.tar.gz lombok-0d7260d0525d68007635df717b2f5520794afbb5.tar.bz2 lombok-0d7260d0525d68007635df717b2f5520794afbb5.zip |
[fixes #2960] [installer] Fix issue with weird chars in eclipse path
Lombok used to attempt to escape 'weird' chars (using a whitelist of chars that need no escaping) when writing out eclipse.ini.
However, there _is no_ escaping mechanism available there. Instead, apparently eclipse/java just reads the chars appearing after
the `-javaagent:` prefix as literally as possible. Therefore, just.. don't escape, and pray. Spaces, colons, and ats have all been confirmed
as working correctly when rendering them literally, and as failing when you attempt to escape them.
Diffstat (limited to 'src/installer/lombok')
-rw-r--r-- | src/installer/lombok/installer/IdeLocation.java | 12 | ||||
-rw-r--r-- | src/installer/lombok/installer/eclipse/EclipseProductLocation.java | 4 |
2 files changed, 3 insertions, 13 deletions
diff --git a/src/installer/lombok/installer/IdeLocation.java b/src/installer/lombok/installer/IdeLocation.java index 6b9a94c6..7cba1e2a 100644 --- a/src/installer/lombok/installer/IdeLocation.java +++ b/src/installer/lombok/installer/IdeLocation.java @@ -64,16 +64,4 @@ public abstract class IdeLocation { return x == null ? p.getPath() : x; } } - - private static final String LEGAL_PATH_CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.-_/"; - private static final String LEGAL_PATH_CHARS_WINDOWS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.,/;'[]{}!@#$^&()-_+= :\\"; - public static String escapePath(String path) { - StringBuilder out = new StringBuilder(); - String legalChars = OsUtils.getOS() == OsUtils.OS.UNIX ? LEGAL_PATH_CHARS : LEGAL_PATH_CHARS_WINDOWS; - for (char c : path.toCharArray()) { - if (legalChars.indexOf(c) == -1) out.append('\\'); - out.append(c); - } - return out.toString(); - } } diff --git a/src/installer/lombok/installer/eclipse/EclipseProductLocation.java b/src/installer/lombok/installer/eclipse/EclipseProductLocation.java index 73f98a35..4cfd07f5 100644 --- a/src/installer/lombok/installer/eclipse/EclipseProductLocation.java +++ b/src/installer/lombok/installer/eclipse/EclipseProductLocation.java @@ -347,8 +347,10 @@ public final class EclipseProductLocation extends IdeLocation { pathPrefix = pathToLombokJarPrefix; } + // NB: You may be tempted to escape this, but don't; there is no possibility to escape this, but + // eclipse/java reads the string following the colon in 'raw' fashion. Spaces, colons - all works fine. newContents.append(String.format( - "-javaagent:%s", escapePath(pathPrefix + "lombok.jar"))).append(OS_NEWLINE); + "-javaagent:%s", pathPrefix + "lombok.jar")).append(OS_NEWLINE); FileOutputStream fos = new FileOutputStream(eclipseIniPath); try { |