Fix T38640: password values showed in tooltips

also disable copying password text.
This commit is contained in:
Campbell Barton 2014-02-15 12:05:51 +11:00
parent 01d9bbaa5e
commit 2413b444d0
Notes: blender-bot 2023-02-14 11:11:02 +01:00
Referenced by issue #38640, StringProperty(subtype='PASSWORD') shows value in tooltip
2 changed files with 16 additions and 6 deletions

View File

@ -1677,6 +1677,13 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data,
return;
}
if (mode == 'c') {
/* disallow copying from any passwords */
if (but->rnaprop && (RNA_property_subtype(but->rnaprop) == PROP_PASSWORD)) {
return;
}
}
if (mode == 'v') {
/* extract first line from clipboard in case of multi-line copies */
int pbuf_len;

View File

@ -325,12 +325,15 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but)
}
if (ELEM3(but->type, TEX, SEARCH_MENU, SEARCH_MENU_UNLINK)) {
/* full string */
ui_get_but_string(but, buf, sizeof(buf));
if (buf[0]) {
BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), TIP_("Value: %s"), buf);
data->color_id[data->totline] = UI_TIP_LC_NORMAL;
data->totline++;
/* better not show the value of a password */
if ((but->rnaprop && (RNA_property_subtype(but->rnaprop) == PROP_PASSWORD)) == 0) {
/* full string */
ui_get_but_string(but, buf, sizeof(buf));
if (buf[0]) {
BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), TIP_("Value: %s"), buf);
data->color_id[data->totline] = UI_TIP_LC_NORMAL;
data->totline++;
}
}
}