[BUG] (solution found) Storage Template: Special characters escaped in album names by HandleBars #1589

Closed
opened 2026-02-05 02:26:51 +03:00 by OVERLORD · 12 comments
Owner

Originally created by @Hely0n on GitHub (Nov 9, 2023).

The bug

I found out, that using Symbols like ' & and some others, the folder name ends up with & instead of "&" etc.

After debugging the code, I found out that the replacement happens inside the template() call in Line 276 of storage-template.service.ts. Here HandleBarsDelegate is called and it seems like it's expected behaviour of Handbars, to escape those characters.

As stated in https://github.com/Handlebars-Net/Handlebars.Net/discussions/463, it can be prevented by using triple-stash ({{{album}}}). I tried to just insert it like this into the settings in the Web UI and it works.

So the current workaround is to use {{{album}}} instead of {{album}} in your storage template.

But what do you think? Should this replacement happen internally by string.replace(), or should it just be stated in the manual to use tripple-stash for albumnames?

The OS that Immich Server is running on

Debian

Version of Immich Server

v1.85.0

Version of Immich Mobile App

doesn't matter

Platform with the issue

  • Server
  • Web
  • Mobile

Your docker-compose.yml content

doesn't matter

Your .env content

doesn't matter

Reproduction steps

1. create Album with "&" in it
2. insert {{album}} into storage template
3. run storage template migration 
4. look at resulting folder name
5. retry with {{{album}}} to check the workaround

Additional information

No response

Originally created by @Hely0n on GitHub (Nov 9, 2023). ### The bug I found out, that using Symbols like `' &` and some others, the folder name ends up with `&` instead of "&" etc. After debugging the code, I found out that the replacement happens inside the template() call in Line 276 of storage-template.service.ts. Here HandleBarsDelegate is called and it seems like it's expected behaviour of Handbars, to escape those characters. As stated in [https://github.com/Handlebars-Net/Handlebars.Net/discussions/463](url), it can be prevented by using triple-stash (`{{{album}}}`). I tried to just insert it like this into the settings in the Web UI and it works. So the current workaround is to use {{{album}}} instead of {{album}} in your storage template. But what do you think? Should this replacement happen internally by string.replace(), or should it just be stated in the manual to use tripple-stash for albumnames? ### The OS that Immich Server is running on Debian ### Version of Immich Server v1.85.0 ### Version of Immich Mobile App doesn't matter ### Platform with the issue - [X] Server - [ ] Web - [ ] Mobile ### Your docker-compose.yml content ```YAML doesn't matter ``` ### Your .env content ```Shell doesn't matter ``` ### Reproduction steps ```bash 1. create Album with "&" in it 2. insert {{album}} into storage template 3. run storage template migration 4. look at resulting folder name 5. retry with {{{album}}} to check the workaround ``` ### Additional information _No response_
Author
Owner

@jrasm91 commented on GitHub (Nov 23, 2023):

I think this work around is good enough for now

@jrasm91 commented on GitHub (Nov 23, 2023): I think this work around is good enough for now
Author
Owner

@jaimetur commented on GitHub (Feb 5, 2025):

This workaround does not work when Album name has a dot "." in the name. Most of my Albums name follow the same template: "yyyy.mm - Album Name" i.e: "2003.07 - Summer Vacations".

When I import my Albums with those names it remove dots in Albums names if I use the following storage template:

{{#if album}}Albums/{{{album}}}{{else}}No-Albums/{{y}}/{{MM}}{{/if}}/IMG_{{y}}{{MM}}{{dd}}_{{HH}}{{mm}}{{ss}}

I would like this to be fixed or have a workaround to it since I don't want to change my Albums template names since 1992.

@jaimetur commented on GitHub (Feb 5, 2025): This workaround does not work when Album name has a dot "." in the name. Most of my Albums name follow the same template: "yyyy.mm - Album Name" i.e: "2003.07 - Summer Vacations". When I import my Albums with those names it remove dots in Albums names if I use the following storage template: {{#if album}}Albums/{{{album}}}{{else}}No-Albums/{{y}}/{{MM}}{{/if}}/IMG_{{y}}{{MM}}{{dd}}_{{HH}}{{mm}}{{ss}} I would like this to be fixed or have a workaround to it since I don't want to change my Albums template names since 1992.
Author
Owner

@Hely0n commented on GitHub (Feb 5, 2025):

The replacement of the dots is there for safety reasons, but maybe it's not necessary. @jrasm91 what do you think? Could dots introduce problems with how the files are handled currently?

@Hely0n commented on GitHub (Feb 5, 2025): The replacement of the dots is there for safety reasons, but maybe it's not necessary. @jrasm91 what do you think? Could dots introduce problems with how the files are handled currently?
Author
Owner

@jaimetur commented on GitHub (Feb 6, 2025):

I don't see any reason for that replacement since all the file systems support that char in folders name and since the Albums are already saved in Immich database with the dots in the Album name.

Even when I download the albums using API REST it save it correctly with the dots in the downloaded folder.

Please remove that replacement to the Handlebars template exports.

@jaimetur commented on GitHub (Feb 6, 2025): I don't see any reason for that replacement since all the file systems support that char in folders name and since the Albums are already saved in Immich database with the dots in the Album name. Even when I download the albums using API REST it save it correctly with the dots in the downloaded folder. Please remove that replacement to the Handlebars template exports.
Author
Owner

@jaimetur commented on GitHub (Feb 11, 2025):

Any news on this?

@jaimetur commented on GitHub (Feb 11, 2025): Any news on this?
Author
Owner

@jaimetur commented on GitHub (Apr 3, 2025):

Is there any news on this? I need this to be addressed before to migrate all my albums to Immich since all my albums since 1995 has dots in their names and I would like to keep them on Immich as well.

@jaimetur commented on GitHub (Apr 3, 2025): Is there any news on this? I need this to be addressed before to migrate all my albums to Immich since all my albums since 1995 has dots in their names and I would like to keep them on Immich as well.
Author
Owner

@jaimetur commented on GitHub (Apr 26, 2025):

@Hely0n Hi Markus, please take a look into this. It would be very very helpful for me to have my Albums folder properly named into my hard drive. If you remove original dots from the album name then all my Albus are completely unsorted on my hard disk and it is completely a mess. I think we can just remove that limitation with no issue. In all other photo apps that I have tried this is possible.

Thank you so much for your patient and comprehension.

@jaimetur commented on GitHub (Apr 26, 2025): @Hely0n Hi Markus, please take a look into this. It would be very very helpful for me to have my Albums folder properly named into my hard drive. If you remove original dots from the album name then all my Albus are completely unsorted on my hard disk and it is completely a mess. I think we can just remove that limitation with no issue. In all other photo apps that I have tried this is possible. Thank you so much for your patient and comprehension.
Author
Owner

@Hely0n commented on GitHub (Apr 26, 2025):

Okay, I‘ll look into this today

@Hely0n commented on GitHub (Apr 26, 2025): Okay, I‘ll look into this today
Author
Owner

@Hely0n commented on GitHub (Apr 26, 2025):

@jaimetur done. Hope it will be approved soon 😊.

Sorry that I didn't react earlier. I didn't have much time in the last months and while fixing it is a quick task, setting up the dev environment of immich always gives me some sort of headaches, as I'm an IntelliJ user on Windows 😅. Finally getting a macbook in two months.

@Hely0n commented on GitHub (Apr 26, 2025): @jaimetur done. Hope it will be approved soon 😊. Sorry that I didn't react earlier. I didn't have much time in the last months and while fixing it is a quick task, setting up the dev environment of immich always gives me some sort of headaches, as I'm an IntelliJ user on Windows 😅. Finally getting a macbook in two months.
Author
Owner

@jaimetur commented on GitHub (Apr 26, 2025):

Thank you @Hely0n

@jaimetur commented on GitHub (Apr 26, 2025): Thank you @Hely0n
Author
Owner

@jaimetur commented on GitHub (Jul 25, 2025):

Hi @Hely0n do you have any update on this?

It has not been implemented yet

@jaimetur commented on GitHub (Jul 25, 2025): Hi @Hely0n do you have any update on this? It has not been implemented yet
Author
Owner

@Hely0n commented on GitHub (Jul 25, 2025):

Hey,
well I'm sorry, but I'm not a core developer of this project and I created this PR and it was closed:
https://github.com/immich-app/immich/pull/17893

I commented accordingly but there was no reaction, so I thought they are taking care of it in another commit... Looks like they didn't.

Looking at your GitHub Account, you seem like a very capable programer. Maybe you could try to just create PR yourself, as I already tried it and don't want to annoy them from my side.  😅 Hope you understand.

@Hely0n commented on GitHub (Jul 25, 2025): Hey, well I'm sorry, but I'm not a core developer of this project and I created this PR and it was closed: https://github.com/immich-app/immich/pull/17893 I commented accordingly but there was no reaction, so I thought they are taking care of it in another commit... Looks like they didn't. Looking at your GitHub Account, you seem like a very capable programer. Maybe you could try to just create PR yourself, as I already tried it and don't want to annoy them from my side.  😅 Hope you understand.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: immich-app/immich#1589