Skip to content

Conversation

@julien-nc
Copy link

@julien-nc julien-nc commented Mar 23, 2021

When a placeholder contains characters like ' " < >, they are replaced by their HTML code. This leads to this kind of issues:
Fix nextcloud/server#26113

Would it be a good solution to decode them here?

@julien-nc julien-nc added the type: enhancement 🚀 New feature or request label Mar 23, 2021
@julien-nc julien-nc force-pushed the enh/decode-html-chars branch from 5f02000 to bf1a594 Compare March 23, 2021 12:30
Copy link
Contributor

@ChristophWurst ChristophWurst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds like a bad idea. you can achieve the same with options.sanitize=false

@julien-nc
Copy link
Author

@ChristophWurst Thanks, that's what I was looking for.

Do you mean on some translate and translatePlural calls, when we know those characters are potentially there?
Or do you mean adding this option here in translate and translatePlural definitions?

I tried it but I'm still getting the HTML char codes for placeholders substitutions.

t('app', 'Hello {name}', { name: 'O\'Brian' }, {}, null, { sanitize: false })

returns Hello O&#39;Brian

@ChristophWurst
Copy link
Contributor

I tried it but I'm still getting the HTML char codes for placeholders substitutions.

t('app', 'Hello {name}', { name: 'O\'Brian' }, {}, null, { sanitize: false })

There is also options.escape

@julien-nc
Copy link
Author

t('app', 'Hello {name}', { name: 'O\'Brian' }, {}, null, { sanitize: false, escape: false })

still returns Hello O&#39;Brian 🤔

@skjnldsv
Copy link
Contributor

skjnldsv commented May 30, 2021

still returns Hello O&#39;Brian

Make sure you're properly using the method from @nextcloud/l10n and not window.t 🤔

@szaimen
Copy link

szaimen commented Jul 2, 2021

Any update here?

@julien-nc
Copy link
Author

@skjnldsv @ChristophWurst Using @nextcloud/l10n@^1.4.1:

import { translate } from '@nextcloud/l10n'
console.debug(translate('app', 'Hello {name}', { name: 'O\'Brian' }, {}, null, { sanitize: false, escape: false }))
// => Hello O&#39;Brian
console.debug(window.t('app', 'Hello {name}', { name: 'O\'Brian' }, {}, null, { sanitize: false, escape: false }))
// => Hello O&#39;Brian

@julien-nc
Copy link
Author

Sorry for the noise. There are too many parameters passed in the examples I gave. All good.

@julien-nc julien-nc closed this Jul 11, 2021
@szaimen
Copy link

szaimen commented Jul 11, 2021

@eneiluj will nextcloud/server#26113 not be fixed then?

@julien-nc
Copy link
Author

@szaimen Yes, thanks for reminding me: nextcloud/server#27912

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

Labels

type: enhancement 🚀 New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Very annoying welcome message issue with data-user-displayname

5 participants