Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Jinja2 template in poster field #679

Open
JavanXD opened this issue Apr 5, 2024 · 2 comments
Open

Feature: Jinja2 template in poster field #679

JavanXD opened this issue Apr 5, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@JavanXD
Copy link

JavanXD commented Apr 5, 2024

The URL of the poster is encoded to something like:

string: /api/webrtc/ws?authSig=xxx-0aCvSaALjijo&poster=%7B%20%2Flocal%2Fimages443%2Fdoorbell.jpg%3F%7B%7B%20as_timestamp(now())%20%7D%7D%0A

I defined the poster in the webrtc card:

poster: "https://xxx/local/imagesxxx/doorbell.jpg?{{ as_timestamp(now()) }}"

Your code implies that Jinja2 templates are supported:

if "{{" in poster or "{%" in poster:
    # support Jinja2 tempaltes inside poster
    poster = Template(poster, hass).async_render()

But adding "{%" does not work as well as executing above Jinja2 template.

@JavanXD
Copy link
Author

JavanXD commented Apr 5, 2024

I found a related error log:

Logger: homeassistant.components.http.security_filter
Quelle: components/http/security_filter.py:65
Integration: HTTP (Dokumentation, Probleme)
Erstmals aufgetreten: 4. April 2024 um 23:48:58 (126 Vorkommnisse)
Zuletzt protokolliert: 00:02:26

Filtered a request with unsafe byte query string: /api/webrtc/ws?authSig=2ODE0NSwiZXhwIjoxNzEyMjY4MTc1fQ.NHLLu-CazKxsto3Heq-UmEQBzygi0UrqakhVmunHcyM&poster=%7B%25%20se%20%2Flocal%2Fimages443%2Fdoorbell.jpg%3F%7B%7B%20as_timestamp(now())%20%7D%7D%0A

Looks like the request is getting filtered by Homeassistants security module.

To fix this could you please base64 the poster field?

@AlexxIT AlexxIT added the enhancement New feature or request label Apr 5, 2024
@AlexxIT
Copy link
Owner

AlexxIT commented Apr 5, 2024

poster_remote: config.poster && (config.poster.indexOf('://') > 0 || config.poster.charAt(0) === '/'),

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants