Skip to content

Commit 62236f4

Browse files
committed
escape special xml characters
1 parent a76717b commit 62236f4

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/main/java/org/cryptomator/linux/quickaccess/DolphinPlaces.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ EntryAndConfig addEntryToConfig(String config, Path target, String displayName)
7171
int insertIndex = config.lastIndexOf("</xbel"); //cannot be -1 due to validation; we do not match the whole end tag, since between tag name and closing bracket can be whitespaces
7272
var adjustedConfig = config.substring(0, insertIndex) //
7373
+ "\n" //
74-
+ ENTRY_TEMPLATE.formatted(target.toUri(), displayName, id).indent(1) //
74+
+ ENTRY_TEMPLATE.formatted(target.toUri(), escapeXML(displayName), id).indent(1) //
7575
+ "\n" //
7676
+ config.substring(insertIndex);
7777
return new EntryAndConfig(new DolphinPlacesEntry(id), adjustedConfig);
@@ -80,6 +80,12 @@ EntryAndConfig addEntryToConfig(String config, Path target, String displayName)
8080
}
8181
}
8282

83+
private String escapeXML(String s) {
84+
return s.replace("&","&amp;") //
85+
.replace("<","&lt;") //
86+
.replace(">","&gt;");
87+
}
88+
8389
private class DolphinPlacesEntry extends FileConfiguredQuickAccessEntry implements QuickAccessEntry {
8490

8591
private final String id;

0 commit comments

Comments
 (0)