jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/389750 )

Change subject: ce.Surface: on paste, make sure clipboardKey spans don't show up
......................................................................


ce.Surface: on paste, make sure clipboardKey spans don't show up

Cleanup is fairly likely to remove an `importantElement` from $pasteTarget,
making it refresh the HTML from the clipboard and deciding to trust it because
it's from *a* VisualEditor. If so, we still need to remove the clipboardKey
span.

Bug: T121588
Change-Id: I830a4dbc5eddd7e00218e87cbfdc9fdd86c86256
---
M src/ce/ve.ce.Surface.js
M tests/ce/ve.ce.Surface.test.js
2 files changed, 45 insertions(+), 0 deletions(-)

Approvals:
  Esanders: Looks good to me, approved
  jenkins-bot: Verified
  Jforrester: Looks good to me, but someone else must approve



diff --git a/src/ce/ve.ce.Surface.js b/src/ce/ve.ce.Surface.js
index 4fac48c..14f6927 100644
--- a/src/ce/ve.ce.Surface.js
+++ b/src/ce/ve.ce.Surface.js
@@ -2137,6 +2137,8 @@
                                htmlDoc = ve.createDocumentFromHtml( 
beforePasteData.html );
                                // Remove the pasteProtect class. See #onCopy.
                                $( htmlDoc ).find( 'span' ).removeClass( 
've-pasteProtect' );
+                               // Remove the clipboard key
+                               $( htmlDoc ).find( 
'span[data-ve-clipboard-key]' ).remove();
                                beforePasteData.context = null;
                        }
                }
diff --git a/tests/ce/ve.ce.Surface.test.js b/tests/ce/ve.ce.Surface.test.js
index c4fcc16..41b279e 100644
--- a/tests/ce/ve.ce.Surface.test.js
+++ b/tests/ce/ve.ce.Surface.test.js
@@ -2026,6 +2026,28 @@
                                msg: 'Span cleanups: only meaningful attributes 
kept'
                        },
                        {
+                               rangeOrSelection: new ve.Range( 1 ),
+                               pasteHtml: '<span 
data-ve-clipboard-key="0.13811087369534492-4">&nbsp;</span><s>Foo</s>',
+                               fromVe: true,
+                               expectedOps: [
+                                       [
+                                               { type: 'retain', length: 1 },
+                                               {
+                                                       type: 'replace',
+                                                       insert: [
+                                                               [ 'F', [ { 
type: 'textStyle/strikethrough', attributes: { nodeName: 's' } } ] ],
+                                                               [ 'o', [ { 
type: 'textStyle/strikethrough', attributes: { nodeName: 's' } } ] ],
+                                                               [ 'o', [ { 
type: 'textStyle/strikethrough', attributes: { nodeName: 's' } } ] ]
+                                                       ],
+                                                       remove: []
+                                               },
+                                               { type: 'retain', length: 29 }
+                                       ]
+                               ],
+                               expectedRangeOrSelection: new ve.Range( 4 ),
+                               msg: 'Span cleanups: clipboard key stripped'
+                       },
+                       {
                                rangeOrSelection: new ve.Range( 0 ),
                                pasteHtml: 'foo\n<!-- StartFragment 
--><p>Bar</p><!--EndFragment-->baz',
                                useClipboardData: true,
@@ -2101,6 +2123,27 @@
                                msg: 'Paste API HTML used if important 
attributes dropped'
                        },
                        {
+                               rangeOrSelection: new ve.Range( 1 ),
+                               pasteHtml: '<span 
data-ve-clipboard-key="0.13811087369534492-4">&nbsp;</span><s 
rel="ve:Alien">Alien</s>',
+                               fromVe: true,
+                               expectedOps: [
+                                       [
+                                               { type: 'retain', length: 1 },
+                                               {
+                                                       type: 'replace',
+                                                       insert: [
+                                                               { type: 
'alienInline' },
+                                                               { type: 
'/alienInline' }
+                                                       ],
+                                                       remove: []
+                                               },
+                                               { type: 'retain', length: 
docLen - 1 }
+                                       ]
+                               ],
+                               expectedRangeOrSelection: new ve.Range( 3 ),
+                               msg: 'Paste API HTML still cleaned up if used 
when important attributes dropped'
+                       },
+                       {
                                rangeOrSelection: {
                                        type: 'table',
                                        tableRange: new ve.Range( 12, 22 ),

-- 
To view, visit https://gerrit.wikimedia.org/r/389750
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I830a4dbc5eddd7e00218e87cbfdc9fdd86c86256
Gerrit-PatchSet: 3
Gerrit-Project: VisualEditor/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: DLynch <[email protected]>
Gerrit-Reviewer: Bartosz DziewoƄski <[email protected]>
Gerrit-Reviewer: DLynch <[email protected]>
Gerrit-Reviewer: Divec <[email protected]>
Gerrit-Reviewer: Esanders <[email protected]>
Gerrit-Reviewer: Jforrester <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to