Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix forceSimpleAmpersand config implementation #2416

Merged
merged 1 commit into from
Sep 14, 2018

Conversation

alexmaris
Copy link
Contributor

@alexmaris alexmaris commented Sep 14, 2018

Run ampersand replacement after the htmlEncodeAttr, otherwise the results are overwritten (#965)

What is the purpose of this pull request?

Bug fix

Does your PR contain necessary tests?

All patches which change the editor code must include tests. You can always read more
on PR testing,
how to set the testing environment and
how to create tests
in the official CKEditor documentation.

This PR contains

  • Unit tests
  • Manual tests

What changes did you make?

Run ampersand replacement after CKEDITOR.tools.htmlEncodeAttr() executes against the given attribute

Closes #965.

Run ampersand replacement after the  htmlEncodeAttr, otherwise the results are overwritten (ckeditor#965)
@mlewand mlewand self-requested a review September 14, 2018 07:02
@mlewand mlewand self-assigned this Sep 14, 2018
Copy link
Contributor

@mlewand mlewand left a comment

Choose a reason for hiding this comment

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

There are a few code style issues, but the fix and unit test looks to be good 👌. Thanks for the contribution!

I have noted most of the code style issues, but I'll correct them in a follow-up to this PR.

@alexmaris please, make sure that you're using latest master or major branch (depending whether you're making a bugfix or a feature) in the future. As your current branch is based on 4.8.0 version and contains conflicts that we need to resolve before we can accept your PR.

// Browsers don't always escape special character in attribute values. (http://dev.ckeditor.com/ticket/4683, http://dev.ckeditor.com/ticket/4719).
attValue = CKEDITOR.tools.htmlEncodeAttr( attValue );

// Run ampersand replacement after the htmlEncodeAttr, otherwise the results are overwritten (https://github.com/ckeditor/ckeditor-dev/issues/965)
Copy link
Contributor

Choose a reason for hiding this comment

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

There's a double space.

Copy link
Contributor

Choose a reason for hiding this comment

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

We refer to GH ticket in a shorter notation, just (#965) is enough. We only use links for other resources, e.g. our old Trac bug tracker.

@@ -39,5 +39,39 @@ bender.test( {
assert.areSame( afterFormat, bot.getData( false, false ) );
} );
} );
},
'test editor config.forceSimpleAmpersand in html element attributes': function () {
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be nice to mention the issue related to this test case too. Also other tests have a one line of spacing between the test cases.

},
'test editor config.forceSimpleAmpersand in html element attributes': function () {
var data = '<p><a href="http://www.blah.com?foo=1&bar=2">Test link</a></p>';
bender.editorBot.create({
Copy link
Contributor

Choose a reason for hiding this comment

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

We use spacing between ({ I can see that you didn't run the linting task. Please make sure to use it in the future, that will show all the code style issues.

bot.setData( data, function () {
var afterFormat = bot.getData( false, false);

// Trigger getData a second time to reveal bug.
Copy link
Contributor

Choose a reason for hiding this comment

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

Actually you're not calling the getData method for a second time, you called setData first, so this comment is misleading.

@mlewand mlewand changed the base branch from master to t/965 September 14, 2018 08:43
@mlewand
Copy link
Contributor

mlewand commented Sep 14, 2018

Changed the target to t/965 branch, where I'll correct the code style issues and rebase the branch onto latest master.

@mlewand mlewand merged commit 596a811 into ckeditor:t/965 Sep 14, 2018
@mlewand mlewand mentioned this pull request Sep 14, 2018
2 tasks
@alexmaris
Copy link
Contributor Author

alexmaris commented Sep 14, 2018

@mlewand my apologies for the sloppy PR, thank you for the help fixing it up and merging the fix.

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.

2 participants