From 05f2fb896cba40aa105354abef59a9a5d0de8f91 Mon Sep 17 00:00:00 2001 From: karwosts <32912880+karwosts@users.noreply.github.com> Date: Mon, 20 Feb 2023 09:14:04 -0800 Subject: [PATCH] Block target picker from adding badly formatted entity (fix history crash) (#15509) --- src/components/ha-target-picker.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/components/ha-target-picker.ts b/src/components/ha-target-picker.ts index 39b240f411..200feca500 100644 --- a/src/components/ha-target-picker.ts +++ b/src/components/ha-target-picker.ts @@ -18,6 +18,7 @@ import { ensureArray } from "../common/array/ensure-array"; import { fireEvent } from "../common/dom/fire_event"; import { computeDomain } from "../common/entity/compute_domain"; import { computeStateName } from "../common/entity/compute_state_name"; +import { isValidEntityId } from "../common/entity/valid_entity_id"; import { computeDeviceName, DeviceRegistryEntry, @@ -351,6 +352,11 @@ export class HaTargetPicker extends LitElement { } const value = ev.detail.value; const target = ev.currentTarget; + + if (target.type === "entity_id" && !isValidEntityId(value)) { + return; + } + target.value = ""; if ( this.value &&