This is an automated email from the ASF dual-hosted git repository.

hansva pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/hop.git


The following commit(s) were added to refs/heads/main by this push:
     new 40ba557c81 password text field sometimes leaks in tooltip, fixes #6639 
(#6921)
40ba557c81 is described below

commit 40ba557c8150c685fedf49bf38f0298f3dcb50ab
Author: Hans Van Akelyen <[email protected]>
AuthorDate: Wed Apr 1 18:07:36 2026 +0200

    password text field sometimes leaks in tooltip, fixes #6639 (#6921)
---
 .../hop/ui/core/gui/GuiCompositeWidgets.java       | 25 ++++++++++++++++------
 .../org/apache/hop/ui/core/widget/TextVar.java     |  4 +++-
 2 files changed, 21 insertions(+), 8 deletions(-)

diff --git 
a/ui/src/main/java/org/apache/hop/ui/core/gui/GuiCompositeWidgets.java 
b/ui/src/main/java/org/apache/hop/ui/core/gui/GuiCompositeWidgets.java
index 8515d03aac..d400416e1c 100644
--- a/ui/src/main/java/org/apache/hop/ui/core/gui/GuiCompositeWidgets.java
+++ b/ui/src/main/java/org/apache/hop/ui/core/gui/GuiCompositeWidgets.java
@@ -44,6 +44,7 @@ import org.apache.hop.ui.core.PropsUi;
 import org.apache.hop.ui.core.dialog.BaseDialog;
 import org.apache.hop.ui.core.widget.ComboVar;
 import org.apache.hop.ui.core.widget.MetaSelectionLine;
+import org.apache.hop.ui.core.widget.PasswordTextVar;
 import org.apache.hop.ui.core.widget.TextVar;
 import org.apache.hop.ui.hopgui.HopGui;
 import org.eclipse.swt.SWT;
@@ -547,14 +548,24 @@ public class GuiCompositeWidgets {
     if (guiElements.isVariablesEnabled()) {
       int style = SWT.BORDER | SWT.SINGLE | SWT.LEFT;
       if (guiElements.isPassword()) {
-        style |= SWT.PASSWORD;
+        String toolTip =
+            StringUtils.isNotEmpty(guiElements.getToolTip()) ? 
guiElements.getToolTip() : null;
+        // PasswordTextVar never mirrors the field value in the tooltip 
(TextVar may on some
+        // platforms when echo char is reported as '\\0' for PASSWORD fields).
+        PasswordTextVar textVar = new PasswordTextVar(variables, parent, 
style, toolTip);
+        PropsUi.setLook(textVar);
+        widgetsMap.put(guiElements.getId(), textVar);
+        addModifyListener(textVar.getTextWidget(), guiElements.getId());
+        control = textVar;
+        text = textVar.getTextWidget();
+      } else {
+        TextVar textVar = new TextVar(variables, parent, style);
+        PropsUi.setLook(textVar);
+        widgetsMap.put(guiElements.getId(), textVar);
+        addModifyListener(textVar.getTextWidget(), guiElements.getId());
+        control = textVar;
+        text = textVar.getTextWidget();
       }
-      TextVar textVar = new TextVar(variables, parent, style);
-      PropsUi.setLook(textVar);
-      widgetsMap.put(guiElements.getId(), textVar);
-      addModifyListener(textVar.getTextWidget(), guiElements.getId());
-      control = textVar;
-      text = textVar.getTextWidget();
     } else {
       int style = SWT.BORDER | SWT.SINGLE | SWT.LEFT;
       if (guiElements.isPassword()) {
diff --git a/ui/src/main/java/org/apache/hop/ui/core/widget/TextVar.java 
b/ui/src/main/java/org/apache/hop/ui/core/widget/TextVar.java
index 4c3fcfe965..3a8e7c16e9 100644
--- a/ui/src/main/java/org/apache/hop/ui/core/widget/TextVar.java
+++ b/ui/src/main/java/org/apache/hop/ui/core/widget/TextVar.java
@@ -216,7 +216,9 @@ public class TextVar extends Composite {
 
   protected ModifyListener getModifyListenerTooltipText(final Text textField) {
     return e -> {
-      if (textField.getEchoChar() == '\0') { // Can't show passwords ;-)
+      // Never put PASSWORD field contents in the tooltip: echo char is not 
always non-\\0 (e.g.
+      // some SWT/Cocoa combinations), so rely on style as well as echo char.
+      if (textField.getEchoChar() == '\0' && (textField.getStyle() & 
SWT.PASSWORD) == 0) {
 
         String tip = textField.getText();
         if (!Utils.isEmpty(tip) && !Utils.isEmpty(toolTipText)) {

Reply via email to