Esanders has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/277232

Change subject: Sanitize the paste context in the same way as the paste data
......................................................................

Sanitize the paste context in the same way as the paste data

Bug: T129310
Change-Id: Iaffb2ae769c8909b9c08c9f3351ecfe776be537e
---
M src/ce/ve.ce.Surface.js
1 file changed, 14 insertions(+), 10 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/VisualEditor/VisualEditor 
refs/changes/32/277232/1

diff --git a/src/ce/ve.ce.Surface.js b/src/ce/ve.ce.Surface.js
index e60da7d..3f58de0 100644
--- a/src/ce/ve.ce.Surface.js
+++ b/src/ce/ve.ce.Surface.js
@@ -1811,6 +1811,18 @@
                documentModel = surfaceModel.getDocument(),
                view = this;
 
+       function sanitize( linearData, keepEmptyContentBranches ) {
+               // If the clipboardKey isn't set (paste from non-VE instance) 
use external import rules
+               if ( !clipboardKey ) {
+                       linearData.sanitize( importRules.external || {}, 
keepEmptyContentBranches );
+                       if ( importRules.all ) {
+                               linearData.sanitize( importRules.all, 
keepEmptyContentBranches );
+                       }
+               } else {
+                       linearData.sanitize( importRules.all || {}, 
keepEmptyContentBranches );
+               }
+       }
+
        // If the selection doesn't collapse after paste then nothing was 
inserted
        if ( !this.nativeSelection.isCollapsed ) {
                return;
@@ -2034,15 +2046,7 @@
                data = pastedDocumentModel.data;
                // Clear metadata
                pastedDocumentModel.metadata = new ve.dm.MetaLinearData( 
pastedDocumentModel.getStore(), new Array( 1 + data.getLength() ) );
-               // If the clipboardKey isn't set (paste from non-VE instance) 
use external import rules
-               if ( !clipboardKey ) {
-                       data.sanitize( importRules.external || {} );
-                       if ( importRules.all ) {
-                               data.sanitize( importRules.all );
-                       }
-               } else {
-                       data.sanitize( importRules.all || {} );
-               }
+               sanitize( data );
                data.remapInternalListKeys( documentModel.getInternalList() );
 
                // Initialize node tree
@@ -2078,7 +2082,7 @@
                        );
                        if ( this.pasteSpecial ) {
                                // The context may have been sanitized, so 
sanitize here as well for comparison
-                               context.sanitize( importRules, true );
+                               sanitize( context, true );
                        }
 
                        // Remove matching context from the left

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iaffb2ae769c8909b9c08c9f3351ecfe776be537e
Gerrit-PatchSet: 1
Gerrit-Project: VisualEditor/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Esanders <[email protected]>

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

Reply via email to