mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-29 01:42:32 +01:00
Fixed secure textfields not to allow text selection, to avoid
compromising sensitive information by pasting it to a terminal.
This commit is contained in:
@@ -16,6 +16,9 @@ Changes since wmaker 0.64.0:
|
|||||||
- better and more robust handling of events (timer, idle, input, X) in
|
- better and more robust handling of events (timer, idle, input, X) in
|
||||||
WMMaskEvent(). Also fixed a bug where input and timer events were not
|
WMMaskEvent(). Also fixed a bug where input and timer events were not
|
||||||
treated for undefined periods of time under some circumstances.
|
treated for undefined periods of time under some circumstances.
|
||||||
|
- fixed secure textfields not to allow text selection, to avoid compromising
|
||||||
|
sensitive information by pasting it to a terminal.
|
||||||
|
|
||||||
|
|
||||||
changes since wmaker 0.63.1:
|
changes since wmaker 0.63.1:
|
||||||
............................
|
............................
|
||||||
|
|||||||
@@ -1256,31 +1256,29 @@ handleTextFieldKeyPress(TextField *tPtr, XEvent *event)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (relay) {
|
if (relay) {
|
||||||
WMRelayToNextResponder(W_VIEW(tPtr), event);
|
WMRelayToNextResponder(W_VIEW(tPtr), event);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Do not allow text selection in secure text fields */
|
||||||
|
if (cancelSelection || tPtr->flags.secure) {
|
||||||
|
lostHandler(tPtr->view, XA_PRIMARY, NULL);
|
||||||
|
|
||||||
if (!cancelSelection) {
|
if (tPtr->selection.count) {
|
||||||
if (tPtr->selection.count != tPtr->cursorPosition - tPtr->selection.position) {
|
tPtr->selection.count = 0;
|
||||||
|
refresh = 1;
|
||||||
|
}
|
||||||
|
tPtr->selection.position = tPtr->cursorPosition;
|
||||||
|
} else {
|
||||||
|
if (tPtr->selection.count != tPtr->cursorPosition - tPtr->selection.position) {
|
||||||
|
|
||||||
tPtr->selection.count = tPtr->cursorPosition - tPtr->selection.position;
|
tPtr->selection.count = tPtr->cursorPosition - tPtr->selection.position;
|
||||||
|
|
||||||
WMPostNotificationName("_lostOwnership", NULL, tPtr);
|
WMPostNotificationName("_lostOwnership", NULL, tPtr);
|
||||||
|
|
||||||
refresh = 1;
|
refresh = 1;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
|
|
||||||
lostHandler(tPtr->view, XA_PRIMARY, NULL);
|
|
||||||
|
|
||||||
if (tPtr->selection.count) {
|
|
||||||
tPtr->selection.count = 0;
|
|
||||||
refresh = 1;
|
|
||||||
}
|
|
||||||
tPtr->selection.position = tPtr->cursorPosition;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*printf("(%d,%d)\n", tPtr->selection.position, tPtr->selection.count);*/
|
/*printf("(%d,%d)\n", tPtr->selection.position, tPtr->selection.count);*/
|
||||||
@@ -1427,7 +1425,12 @@ handleTextFieldActionEvents(XEvent *event, void *data)
|
|||||||
tPtr->cursorPosition =
|
tPtr->cursorPosition =
|
||||||
pointToCursorPosition(tPtr, event->xmotion.x);
|
pointToCursorPosition(tPtr, event->xmotion.x);
|
||||||
|
|
||||||
tPtr->selection.count = tPtr->cursorPosition - tPtr->selection.position;
|
/* Do not allow text selection in secure textfields */
|
||||||
|
if (tPtr->flags.secure) {
|
||||||
|
tPtr->selection.position = tPtr->cursorPosition;
|
||||||
|
}
|
||||||
|
|
||||||
|
tPtr->selection.count = tPtr->cursorPosition - tPtr->selection.position;
|
||||||
|
|
||||||
if (tPtr->selection.count != 0) {
|
if (tPtr->selection.count != 0) {
|
||||||
if (!tPtr->flags.ownsSelection) {
|
if (!tPtr->flags.ownsSelection) {
|
||||||
@@ -1464,12 +1467,11 @@ handleTextFieldActionEvents(XEvent *event, void *data)
|
|||||||
textWidth = WMWidthOfString(tPtr->font, tPtr->text, tPtr->textLen);
|
textWidth = WMWidthOfString(tPtr->font, tPtr->text, tPtr->textLen);
|
||||||
if (tPtr->flags.enabled && !tPtr->flags.focused) {
|
if (tPtr->flags.enabled && !tPtr->flags.focused) {
|
||||||
WMSetFocusToWidget(tPtr);
|
WMSetFocusToWidget(tPtr);
|
||||||
|
|
||||||
} else if (tPtr->flags.focused) {
|
} else if (tPtr->flags.focused) {
|
||||||
tPtr->selection.position = tPtr->cursorPosition;
|
tPtr->selection.position = tPtr->cursorPosition;
|
||||||
tPtr->selection.count = 0;
|
tPtr->selection.count = 0;
|
||||||
}
|
}
|
||||||
if(textWidth < tPtr->usableWidth) {
|
if (textWidth < tPtr->usableWidth) {
|
||||||
tPtr->cursorPosition = pointToCursorPosition(tPtr,
|
tPtr->cursorPosition = pointToCursorPosition(tPtr,
|
||||||
event->xbutton.x - tPtr->usableWidth
|
event->xbutton.x - tPtr->usableWidth
|
||||||
+ textWidth);
|
+ textWidth);
|
||||||
@@ -1544,8 +1546,9 @@ handleTextFieldActionEvents(XEvent *event, void *data)
|
|||||||
|
|
||||||
move = 0;
|
move = 0;
|
||||||
|
|
||||||
if (event->xbutton.time - lastButtonReleasedEvent
|
if (!tPtr->flags.secure &&
|
||||||
<= WINGsConfiguration.doubleClickDelay) {
|
event->xbutton.time - lastButtonReleasedEvent
|
||||||
|
<= WINGsConfiguration.doubleClickDelay) {
|
||||||
tPtr->selection.position = 0;
|
tPtr->selection.position = 0;
|
||||||
tPtr->selection.count = tPtr->textLen;
|
tPtr->selection.count = tPtr->textLen;
|
||||||
paintTextField(tPtr);
|
paintTextField(tPtr);
|
||||||
|
|||||||
Reference in New Issue
Block a user