Single quotes are not being escaped in XML CDATA

We’re using Android XML files and noticed that if the strings are enclosed in CDATA tag, the single quotes in translations are not being escaped. That makes our build crash.

Escaping quotes with backslashes is required by our system even for CDATA strings. Any workaround to solve it quickly?

6 Likes

Hi Diego,

Yes, we have a special script for such cases so you will get escaped quotes for all strings, even those included in CDATA tag. Can you please tell me your project ID? I will apply the mentioned script to it and you’ll get the correct strings on export :slight_smile:

2 Likes

@Yuliia Great, here it is: 452334

Hi Diego, it’s done already :slight_smile:

@Yuliia works great! Thanks a lot, you’re a star!

2 Likes

@Yuliia Can you help me? I have the same problem with this thread, my project id is 613973

Hi @maxrave, I’ve linked the script with your project (for Android files, to escape apostrophes in CDATA). Please try to build the project to confirm how it works for you.

We’ll keep an eye on this thread because it has been 4 years since the last time this processor was used, maybe it’s a little “rusty” :slight_smile:

@Dima Hi Dima, thanks for your support, but now my project was upgraded to Compose Multiplatform, and Jetbrains fixed the escape issue, so right now, can you help me to unlink the script in my project? My project id is 613973

Hi @maxrave, thank you for letting us know. Sure, already removed the script

Hi, Crowdin still export escape apostrophes in my project :(((

Hi @maxrave
I’ve set a full re-build of the project, please try to download a project build again


Crowdin plugin in Android Studio still export it for me, my project :)))

Hello @maxrave,
Sorry to hear that it didn’t work as expected!

I have officially escalated this to our engineering team.

We will notify you as soon as we get their feedback.
Thanks in advance!

1 Like

Hey @maxrave, it doesn’t seem the mentioned string is located within CDATA. According to specs, apostrophe should be escaped inside Android XML

I’m not certain if it’s a good idea to proceed, but you can set up a custom post-export processor to unescape quotes:

if (fileName.endsWith('.xml')) {
    content = content.replace(/\\'/g, "'");
}

The processor itself:

There is also GPT available, which allows you to create your own code for processors: