Catrope has uploaded a new change for review.

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


Change subject: Always deep copy when writing to and reading from the fake 
clipboard
......................................................................

Always deep copy when writing to and reading from the fake clipboard

Otherwise, changes to deeply nested structures like template blobs or
references will leak from the data model into the clipboard data.

Change-Id: I85d8d311f676d45856f30b3747e7383c70c95460
---
M modules/ve/ce/ve.ce.Surface.js
1 file changed, 5 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor 
refs/changes/67/82567/1

diff --git a/modules/ve/ce/ve.ce.Surface.js b/modules/ve/ce/ve.ce.Surface.js
index 357597f..705d6a7 100644
--- a/modules/ve/ce/ve.ce.Surface.js
+++ b/modules/ve/ce/ve.ce.Surface.js
@@ -656,7 +656,8 @@
                }
        }
        // Set clipboard
-       this.clipboard[key] = slice;
+       // Take a copy to prevent later changes in the data model affecting 
this.clipboard
+       this.clipboard[key] = ve.copy( slice );
 };
 
 /**
@@ -722,6 +723,7 @@
                try {
                        // Try to paste in the orignal data
                        // Take a copy to prevent the data being annotated a 
second time in the catch block
+                       // and to prevent actions in the data model affecting 
view.clipboard
                        pasteData = ve.copy( slice.getData() );
 
                        // Annotate
@@ -735,7 +737,8 @@
                        );
                } catch ( e ) {
                        // If that fails, balance the data before pasting
-                       pasteData = slice.getBalancedData();
+                       // Take a copy to prevent actions in the data model 
affecting view.clipboard
+                       pasteData = ve.copy( slice.getBalancedData() );
 
                        // Annotate
                        ve.dm.Document.addAnnotationsToData( pasteData, 
this.model.getInsertionAnnotations() );

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I85d8d311f676d45856f30b3747e7383c70c95460
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Catrope <[email protected]>

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

Reply via email to