Skip to content

Conversation

@bryghtlabs-richard
Copy link
Contributor

I'm not sure this is the right approach. It looks like lib/parser.js has a mechanism to un-escape input files, and lib/compiler_template.js has a mechanism to escape output files, and that seemed to make sense, so I was expecting both to run, but it seems esc() was running on the raw text, which was then double-escaped.

This change removes esc().

Fixes #66

@teaalltr
Copy link

Hi @bryghtlabs-richard it works for me, could you merge the PR? Thank you!

@paaspaas00
Copy link

paaspaas00 commented Sep 18, 2024

Hi @bryghtlabs-richard it works for me, could you merge the PR? Thank you!

@bryghtlabs-richard hold on, I'm testing with apostrophe escaping ( slash + ' ), will be able to tell if it works properly in a day or so

@bryghtlabs-richard
Copy link
Contributor Author

Hi all, I'm not a maintainer of lv_i18n - we'll need their review and help, and with anything it's worth taking the time to get it right. Also, I'm not a JS developer, please take this patch with a grain of salt, and I'm not sure this is the right way to handle this - the other option will be to ensure the keys/values get de-escaped on parsing, then re-escaped on output.

@kisvegabor
Copy link
Member

cc @puzrin

So we assume that the characters are correctly escaped in the input strings already, so we can use them as they are, right?

@bryghtlabs-richard
Copy link
Contributor Author

bryghtlabs-richard commented Sep 30, 2024

It seems to work that way, YAML and C seem to share a lot of escape sequences, I tried " and it compiled properly with this patch, but we should check any differences in the language escapes. There are some tests for C unescaping, I'll try to get those running when I look at this again. @rlidwka , any thoughts?

@vortex-surfer
Copy link
Contributor

vortex-surfer commented Jan 10, 2025

Hi @bryghtlabs-richard, I rebased your commit on master. It seems to work for me but I also am not a JS developer and cannot comment on any possible corner cases.

0001-fix-double-escaping-of-newlines.patch

Edit: the provided patch contained errors, now it should work

@raoulh
Copy link

raoulh commented Jan 17, 2025

I came across this exact bug, why isn't this PR merged?

@bryghtlabs-richard
Copy link
Contributor Author

I haven't had time to finish testing each escape sequence. Feel free to pick this up.

@kisvegabor
Copy link
Member

Can someone pick up this PR and test with the proposed patch?

@bryghtlabs-richard
Copy link
Contributor Author

I looked at this again. Here's why I don't understand it: if JavaScript has a line containing a newline character, it should absolutely be escaped. Is the YAML parser not converting '\n' to a newline character? Probably not - I don't think that means anything to Yaml.

I came to think that I should make my YML files contain a line break using the ?: syntax, but those lines get joined with spaces into a key, so that doesn't work.

Maybe the answer is to replace translation keys with newlines with an intermediate text key without newlines, then translate those to all languages(including the default lang)?

@bluecraank
Copy link

Any updates here?

@bryghtlabs-richard
Copy link
Contributor Author

Need to merge #88 first

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

corrupted escape characters

7 participants