Hello everyone (and everyone else…),
Hi @jean_bruder ,
Thanks for your feedback!
Actually, it all depends on the calendar source, some tools add special HTML characters in the titles/descriptions.
You’re right, we could remove these special characters to make it cleaner
@bertrandda I think we could modify calendar.formaters.js to decode name, location and description, what do you think?
Hi,
I took a quick look and I think I managed to reproduce the issue. Maybe I’m wrong, but I don’t think the problem is with Caldav. It seems that whenever an apostrophe or other special character is in a variable « compiled » by the Handlebars library, the library escapes the character.
Example (screenshot below), when I look in the database the apostrophe is alone, if I console.log before the compile() the apostrophe is alone as well, but right after in the result if I console.log it adds extra characters.
I proposed a PR, let me know what you think.
master ← bertrandda:fix/escaped-char-variable
ouvert 06:02PM - 25 Jun 26 UTC
### Pull Request check-list
To ensure your Pull Request can be accepted as fa… st as possible, make sure to review and check all of these items:
- [ ] If your changes affect the code, did you write the tests?
- [ ] Are tests passing? (`npm test` on both front/server)
- [ ] Is the linter passing? (`npm run eslint` on both front/server)
- [ ] Did you run prettier? (`npm run prettier` on both front/server)
- [ ] If you are adding a new feature/service, did you run the integration comparator? (`npm run compare-translations` on front)
- [ ] Did you test this pull request in real life? With real devices? If this development is a big feature or a new service, we recommend that you provide a Docker image to the community ([forum](https://community.gladysassistant.com/)) for testing before merging.
- [ ] If your changes modify the API (REST or Node.js), did you modify the API documentation? (Documentation is based on comments in code)
- [ ] If you are adding a new features/services which needs explanation, did you modify the user documentation? See [the GitHub repo](https://github.com/GladysAssistant/v4-website) and the [website](https://gladysassistant.com).
- [ ] Did you add fake requests data for the demo mode (`front/src/config/demo.js`) so that the demo website is working without a backend? (if needed) See [https://demo.gladysassistant.com](https://demo.gladysassistant.com).
NOTE: these things are not required to open a PR and can be done afterwards / while the PR is open.
### Description of change
Please provide a description of the change here. It's always best with screenshots, so don't hesitate to add some!
https://community.gladysassistant.com/t/valeurs-de-calendrier-dans-une-scene-et-caracteres-specaux-accentes/10273/2
Here is a screenshot (first message before the fix, second message after the fix)
Thanks for investigating, that looks good to me!
However, I think you can extend this behavior to the other affected areas, otherwise we might encounter the same issue elsewhere
I still see quite a few Handlebars.compile instances in the project.
And don’t hesitate to add a small test along the way, that way we ensure the behavior remains stable over time
@bertrandda actually I hadn’t noticed, but it was indeed the case in your PR, I’ve merged it, it will be in the next version of Gladys
pierre-gilles:
@bertrandda actually I hadn’t noticed, but it was indeed the case in your PR, I’ve merged it, it will be in the next version of Gladys
No, you were right, the PR wasn’t complete. I added the noescape parameter in the remaining Handlebars.compile calls. I also added a test
master ← bertrandda:fix/noescape-handlebar
ouvert 06:27PM - 30 Jun 26 UTC
### Pull Request check-list
To ensure your Pull Request can be accepted as fa… st as possible, make sure to review and check all of these items:
- [ ] If your changes affect the code, did you write the tests?
- [ ] Are tests passing? (`npm test` on both front/server)
- [ ] Is the linter passing? (`npm run eslint` on both front/server)
- [ ] Did you run prettier? (`npm run prettier` on both front/server)
- [ ] If you are adding a new feature/service, did you run the integration comparator? (`npm run compare-translations` on front)
- [ ] Did you test this pull request in real life? With real devices? If this development is a big feature or a new service, we recommend that you provide a Docker image to the community ([forum](https://community.gladysassistant.com/)) for testing before merging.
- [ ] If your changes modify the API (REST or Node.js), did you modify the API documentation? (Documentation is based on comments in code)
- [ ] If you are adding a new features/services which needs explanation, did you modify the user documentation? See [the GitHub repo](https://github.com/GladysAssistant/v4-website) and the [website](https://gladysassistant.com).
- [ ] Did you add fake requests data for the demo mode (`front/src/config/demo.js`) so that the demo website is working without a backend? (if needed) See [https://demo.gladysassistant.com](https://demo.gladysassistant.com).
NOTE: these things are not required to open a PR and can be done afterwards / while the PR is open.
### Description of change
Add `noescape` param for all Handlebars.compile functions to avoid html encoding chars in rendered texts.
Also added a test on one compile with `'`
https://community.gladysassistant.com/t/valeurs-de-calendrier-dans-une-scene-et-caracteres-specaux-accentes/10273/4
## Summary by CodeRabbit
* **Bug Fixes**
* Improved rendering of dynamic text and template-based values so special characters, including apostrophes, are preserved correctly.
* Fixed several scene actions that use generated content, including messages, HTTP requests, delays, conditions, and device values, to display or send text more reliably.
Hello @pierre-gilles and @bertrandda
I can confirm that with version 4.81.0 running on my system, the escaping of special characters is fixed: no more strange things sent in messages and inconsistent event pronunciation now!
Once again, I can only thank you
Jean
Excellent! In the next version of Gladys, we’ll fix this bug in other places because it wasn’t the only one.
Thanks for reporting the bug and thanks to @bertrandda for the fix