Skip to content

Decode html characters#244

Closed
julien-nc wants to merge 1 commit into
masterfrom
enh/decode-html-chars
Closed

Decode html characters#244
julien-nc wants to merge 1 commit into
masterfrom
enh/decode-html-chars

Conversation

@julien-nc

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

Copy link
Copy Markdown

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
Signed-off-by: Julien Veyssier <eneiluj@posteo.net>
@julien-nc julien-nc force-pushed the enh/decode-html-chars branch from 5f02000 to bf1a594 Compare March 23, 2021 12:30

@ChristophWurst ChristophWurst left a comment

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Author
t('app', 'Hello {name}', { name: 'O\'Brian' }, {}, null, { sanitize: false, escape: false })

still returns Hello O&#39;Brian 🤔

@skjnldsv

skjnldsv commented May 30, 2021

Copy link
Copy Markdown
Contributor

still returns Hello O&#39;Brian

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

@szaimen

szaimen commented Jul 2, 2021

Copy link
Copy Markdown

Any update here?

@julien-nc

Copy link
Copy Markdown
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
Copy Markdown
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

szaimen commented Jul 11, 2021

Copy link
Copy Markdown

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

@julien-nc

Copy link
Copy Markdown
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

4 participants