Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure the product *.ini is loaded and saved using the native encoding #482

Merged
merged 1 commit into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.equinox.frameworkadmin.equinox;singleton:=true
Bundle-Version: 1.3.100.qualifier
Bundle-Version: 1.3.200.qualifier
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Import-Package: org.eclipse.equinox.frameworkadmin;version="[2.0.0,3.0.0)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,8 @@ void save(EquinoxLauncherData launcherData, boolean backup) throws IOException {

// only write the file if we actually have content
if (newlines.size() > 0) {
try (BufferedWriter bw = new BufferedWriter(new FileWriter(launcherConfigFile));) {
try (BufferedWriter bw = new BufferedWriter(
new FileWriter(launcherConfigFile, FileUtils.getNativeCharset()));) {
for (String arg : newlines) {
if (arg == null)
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import java.io.*;
import java.net.*;
import java.nio.charset.Charset;
import java.util.*;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.URIUtil;
Expand Down Expand Up @@ -214,9 +215,12 @@ public static URI fromFileURL(String url) throws URISyntaxException {
* Loads an ini file, returning a list of all non-blank lines in the file. Like
* eclipseConfig.c/readConfigFile() comment lines ('#' its first character) are
* skipped too.
*
* This must load the content using the native system encoding because that's
* what the native launcher executable does.
*/
public static List<String> loadFile(File file) throws IOException {
try (BufferedReader br = new BufferedReader(new FileReader(file));) {
try (BufferedReader br = new BufferedReader(new FileReader(file, getNativeCharset()));) {
String line;
List<String> list = new ArrayList<>();
while ((line = br.readLine()) != null) {
Expand All @@ -230,4 +234,13 @@ public static List<String> loadFile(File file) throws IOException {
}
}

/**
* The encoding used for reading and writing the ini file. This must be the
* native encoding; as of Java 21, the default encoding is UTF-8.
*/
public static Charset getNativeCharset() {
String encoding = System.getProperty("native.encoding"); //$NON-NLS-1$
return encoding != null ? Charset.forName(encoding) : Charset.defaultCharset();
}

}
2 changes: 1 addition & 1 deletion features/org.eclipse.equinox.p2.core.feature/feature.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<feature
id="org.eclipse.equinox.p2.core.feature"
label="%featureName"
version="1.7.100.qualifier"
version="1.7.200.qualifier"
provider-name="%providerName"
license-feature="org.eclipse.license"
license-feature-version="0.0.0">
Expand Down
2 changes: 1 addition & 1 deletion features/org.eclipse.equinox.p2.extras.feature/feature.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<feature
id="org.eclipse.equinox.p2.extras.feature"
label="%featureName"
version="1.4.2300.qualifier"
version="1.4.2400.qualifier"
provider-name="%providerName"
license-feature="org.eclipse.license"
license-feature-version="0.0.0">
Expand Down
2 changes: 1 addition & 1 deletion features/org.eclipse.equinox.p2.rcp.feature/feature.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<feature
id="org.eclipse.equinox.p2.rcp.feature"
label="%featureName"
version="1.4.2300.qualifier"
version="1.4.2400.qualifier"
provider-name="%providerName"
license-feature="org.eclipse.license"
license-feature-version="0.0.0">
Expand Down
2 changes: 1 addition & 1 deletion features/org.eclipse.equinox.p2.sdk/feature.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<feature
id="org.eclipse.equinox.p2.sdk"
label="%featureName"
version="3.11.2300.qualifier"
version="3.11.2400.qualifier"
provider-name="%providerName"
license-feature="org.eclipse.license"
license-feature-version="0.0.0">
Expand Down
2 changes: 1 addition & 1 deletion features/org.eclipse.equinox.p2.user.ui/feature.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<feature
id="org.eclipse.equinox.p2.user.ui"
label="%featureName"
version="2.4.2300.qualifier"
version="2.4.2400.qualifier"
provider-name="%providerName"
license-feature="org.eclipse.license"
license-feature-version="0.0.0">
Expand Down
2 changes: 1 addition & 1 deletion features/org.eclipse.equinox.server.p2/feature.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<feature
id="org.eclipse.equinox.server.p2"
label="%featureName"
version="1.12.1200.qualifier"
version="1.12.1300.qualifier"
provider-name="%providerName"
license-feature="org.eclipse.license"
license-feature-version="0.0.0">
Expand Down
Loading