Skip to content

Fix manual tests language.ui value#18501

Open
l-lejman wants to merge 10 commits into
masterfrom
cc/7297
Open

Fix manual tests language.ui value#18501
l-lejman wants to merge 10 commits into
masterfrom
cc/7297

Conversation

@l-lejman

@l-lejman l-lejman commented May 9, 2025

Copy link
Copy Markdown
Contributor

Suggested merge commit message (convention)

Tests: Fix manual tests language.ui value.


Additional information

Closes https://github.com/cksource/ckeditor5-commercial/issues/7297.

@l-lejman l-lejman requested review from f1ames and scofalik May 12, 2025 14:13
Comment thread packages/ckeditor5-utils/src/config.ts Outdated
target[ part ] = Object.create( null );
// If target[part] is not an object or array, initialize as empty object.
if ( typeof target[ part ] !== 'object' || target[ part ] === null ) {
target[ part ] = {};

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.

Why such a change? This was changed recently to avoid prototype pollution.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Because it cause error in mathtype manual test (inside wiris mathtype lib).
On objects created this way (Object.create( null )) there is no hasOwnProperty method so if we create language ui by using define mathtype throws error when trying to read language because they use hasOwnProperty.

@Mati365 Mati365 May 28, 2025

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I agree with @niegowski comment. This part of the code is responsible for preventing prototype pollution, which is also flagged by code scanners. The change is fully intentional. Bypassing security measures just to apply a bugfix isn’t a good practice. It’s better to fix this on the side of the library that relies on this behavior.

Comment thread packages/ckeditor5-utils/src/config.ts Outdated
// We take care of proper config structure.
if ( !isPlainObject( target[ name ] ) ) {
target[ name ] = Object.create( null );
target[ name ] = {};

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.

Why such a change? This was changed recently to avoid prototype pollution.

Comment on lines +166 to +173
/**
* Function _translate from translation-service.ts gets translations from
* global.window.CKEDITOR_TRANSLATIONS when translations injected into Locale are empty.
* Value of global.window.CKEDITOR_TRANSLATIONS is provided by CKEditorTranslationsPlugin from
* ckeditor5-dev-translations package (for example in manual tests) when --language flag is used.
* Function _translate is called often and has no access to the editing editor config, so here is a better place to
* check if translations will be taken from dev-translations, and if yes – update config.language.ui value.
*/

@Mati365 Mati365 May 28, 2025

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

imho, this comment could be clearer. Two things:

  1. It sounds like global.window.CKEDITOR_TRANSLATIONS is always set by CKEditorTranslationsPlugin, but that’s not true. It can also come from translation files loaded from a CDN, so we shouldn’t assume it always comes from the plugin.
  2. Without reading the issue (#7297), it’s hard to tell what the problem is and why this if is needed. The comment should explain it in a more straightforward way.

@l-lejman

Copy link
Copy Markdown
Contributor Author

i added pr to wiris to resolve mathtype manual error wiris/html-integrations#1107

@CKEditorBot

Copy link
Copy Markdown
Collaborator

There has been no activity on this PR for the past year. We've marked it as stale and will close it in 30 days. We understand it may still be relevant, so if you're interested in the contribution, leave a comment or reaction under this PR.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants