Skip to content

Commit c128dbd

Browse files
authored
[28395] Laufwerksbuchstabe in URI-Pfad kanonisieren (#957)
1 parent 0a14739 commit c128dbd

2 files changed

Lines changed: 39 additions & 5 deletions

File tree

bundles/ch.elexis.core.services/src/ch/elexis/core/services/internal/VirtualFilesystemHandle.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -490,8 +490,10 @@ public IVirtualFilesystemHandle subDir(String subDir) throws IOException {
490490
}
491491

492492
URI _uri = null;
493-
if (uri.getAuthority() != null && uri.getAuthority().length() > 0 && uri.getAuthority().charAt(1) == ':') {
494-
// workaround - URIUtil "swallows" C: authority
493+
if (uri.getAuthority() != null && uri.getAuthority().length() > 1 && uri.getAuthority().charAt(1) == ':') {
494+
// workaround - URIUtil "swallows" C: authority. Only reachable for legacy
495+
// file://C:/ uris, IVirtualFilesystemService#stringToURI does not create
496+
// them anymore
495497
String _cur = uri.toString();
496498
if (!_cur.endsWith("/")) {
497499
_cur += "/";
@@ -517,8 +519,10 @@ public IVirtualFilesystemHandle subFile(String subFile) throws IOException {
517519
throw new IllegalArgumentException("must not start with /");
518520
}
519521
URI _uri = null;
520-
if (uri.getAuthority() != null && uri.getAuthority().length() > 0 && uri.getAuthority().charAt(1) == ':') {
521-
// workaround - URIUtil "swallows" C: authority
522+
if (uri.getAuthority() != null && uri.getAuthority().length() > 1 && uri.getAuthority().charAt(1) == ':') {
523+
// workaround - URIUtil "swallows" C: authority. Only reachable for legacy
524+
// file://C:/ uris, IVirtualFilesystemService#stringToURI does not create
525+
// them anymore
522526
try {
523527
_uri = IVirtualFilesystemService.stringToURI(uri.toString() + subFile);
524528
} catch (MalformedURLException | URISyntaxException e) {

bundles/ch.elexis.core.ui.e4/src/ch/elexis/core/ui/e4/jface/preference/URIFieldEditor.java

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ public URIFieldEditor(String name, String labelText, Composite parent) {
4343
setErrorMessage(JFaceResources.getString("DirectoryFieldEditor.errorMessage"));//$NON-NLS-1$
4444
setChangeButtonText(JFaceResources.getString("openBrowse"));//$NON-NLS-1$
4545
createControl(parent);
46-
getTextControl().setEchoChar('*');
4746
getTextControl().setEnabled(false);
4847
}
4948

@@ -54,6 +53,37 @@ protected void doLoad() {
5453
getTextControl().setText(value);
5554
oldValue = value;
5655
}
56+
updateEchoChar();
57+
}
58+
59+
@Override
60+
protected void doLoadDefault() {
61+
super.doLoadDefault();
62+
updateEchoChar();
63+
}
64+
65+
@Override
66+
public void setStringValue(String value) {
67+
super.setStringValue(value);
68+
updateEchoChar();
69+
}
70+
71+
private void updateEchoChar() {
72+
if (getTextControl() != null && !getTextControl().isDisposed()) {
73+
getTextControl().setEchoChar(containsPassword(getStringValue()) ? '*' : '\0');
74+
}
75+
}
76+
77+
private boolean containsPassword(String value) {
78+
if (StringUtils.isBlank(value)) {
79+
return false;
80+
}
81+
try {
82+
String userInfo = new URI(value).getUserInfo();
83+
return userInfo != null && userInfo.indexOf(':') > 0;
84+
} catch (URISyntaxException e) {
85+
return false;
86+
}
5787
}
5888

5989
@Override

0 commit comments

Comments
 (0)