Escape special characters of automation ID in URL (#19790)

* Escape special character of automation ID in URL

* Use encodeURIComponent
This commit is contained in:
Paul Bottein 2024-02-28 14:29:00 +01:00 committed by GitHub
parent b982884933
commit 94f74308d8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 23 additions and 9 deletions

View File

@ -568,7 +568,7 @@ class HaConfigAreaPage extends LitElement {
<a <a
href=${ifDefined( href=${ifDefined(
entityState.attributes.id entityState.attributes.id
? `/config/automation/edit/${entityState.attributes.id}` ? `/config/automation/edit/${encodeURIComponent(entityState.attributes.id)}`
: undefined : undefined
)} )}
> >

View File

@ -172,7 +172,11 @@ export class HaAutomationEditor extends KeyboardShortcutMixin(LitElement) {
</ha-list-item> </ha-list-item>
${stateObj && this._config && this.narrow ${stateObj && this._config && this.narrow
? html`<a href="/config/automation/trace/${this._config.id}"> ? html`<a
href="/config/automation/trace/${encodeURIComponent(
this._config.id!
)}"
>
<ha-list-item graphic="icon"> <ha-list-item graphic="icon">
${this.hass.localize( ${this.hass.localize(
"ui.panel.config.automation.editor.show_trace" "ui.panel.config.automation.editor.show_trace"
@ -563,7 +567,9 @@ export class HaAutomationEditor extends KeyboardShortcutMixin(LitElement) {
if (this._config?.id) { if (this._config?.id) {
const result = await this.confirmUnsavedChanged(); const result = await this.confirmUnsavedChanged();
if (result) { if (result) {
navigate(`/config/automation/trace/${this._config.id}`); navigate(
`/config/automation/trace/${encodeURIComponent(this._config.id)}`
);
} }
} }
} }

View File

@ -435,7 +435,9 @@ class HaAutomationPicker extends LitElement {
}); });
return; return;
} }
navigate(`/config/automation/trace/${automation.attributes.id}`); navigate(
`/config/automation/trace/${encodeURIComponent(automation.attributes.id)}`
);
} }
private async _toggle(automation): Promise<void> { private async _toggle(automation): Promise<void> {
@ -530,9 +532,11 @@ class HaAutomationPicker extends LitElement {
); );
if (automation?.attributes.id) { if (automation?.attributes.id) {
navigate(`/config/automation/edit/${automation.attributes.id}`); navigate(
`/config/automation/edit/${encodeURIComponent(automation.attributes.id)}`
);
} else { } else {
navigate(`/config/automation/show/${ev.detail.id}`); navigate(`/config/automation/show/${encodeURIComponent(ev.detail.id)}`);
} }
} }

View File

@ -106,7 +106,9 @@ export class HaAutomationTrace extends LitElement {
? html` ? html`
<a <a
class="trace-link" class="trace-link"
href="/config/automation/edit/${stateObj.attributes.id}" href="/config/automation/edit/${encodeURIComponent(
stateObj.attributes.id
)}"
slot="toolbar-icon" slot="toolbar-icon"
> >
<mwc-button> <mwc-button>
@ -140,7 +142,9 @@ export class HaAutomationTrace extends LitElement {
? html` ? html`
<a <a
class="trace-link" class="trace-link"
href="/config/automation/edit/${stateObj.attributes.id}" href="/config/automation/edit/${encodeURIComponent(
stateObj.attributes.id
)}"
> >
<mwc-list-item graphic="icon"> <mwc-list-item graphic="icon">
${this.hass.localize( ${this.hass.localize(

View File

@ -431,7 +431,7 @@ export class HaConfigDevicePage extends LitElement {
<a <a
href=${ifDefined( href=${ifDefined(
entityState.attributes.id entityState.attributes.id
? `/config/automation/edit/${entityState.attributes.id}` ? `/config/automation/edit/${encodeURIComponent(entityState.attributes.id)}`
: undefined : undefined
)} )}
> >