diff options
author | Ananya Sen | 2012-06-07 11:55:36 -0700 |
---|---|---|
committer | Ananya Sen | 2012-06-07 11:55:36 -0700 |
commit | aea0e6879abfef02a827ed239ef091c3b96d6eb2 (patch) | |
tree | aef4575d88711ea16667432c6ff3e717b93e71ec /js/controllers | |
parent | f386d6c23dd47e874faf18d39c325d75d8b00154 (diff) | |
download | ninja-aea0e6879abfef02a827ed239ef091c3b96d6eb2.tar.gz |
- cleanse html for copying from outer application
Signed-off-by: Ananya Sen <Ananya.Sen@motorola.com>
Diffstat (limited to 'js/controllers')
-rw-r--r-- | js/controllers/clipboard-controller.js | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/js/controllers/clipboard-controller.js b/js/controllers/clipboard-controller.js index 38102512..e08cb12b 100644 --- a/js/controllers/clipboard-controller.js +++ b/js/controllers/clipboard-controller.js | |||
@@ -227,28 +227,41 @@ var ClipboardController = exports.ClipboardController = Montage.create(Component | |||
227 | pastedElements.push(node); | 227 | pastedElements.push(node); |
228 | } | 228 | } |
229 | } | 229 | } |
230 | |||
231 | this.application.ninja.selectionController.selectElements(pastedElements); | ||
232 | this.application.ninja.currentDocument.model.needsSave = true; | ||
230 | } | 233 | } |
231 | }, | 234 | }, |
232 | 235 | ||
233 | //paste from external applicaitons | 236 | //paste from external applicaitons |
234 | pasteFromExternalSource:{//todo: change to pasteNinja, pasteHTML, etc | 237 | pasteFromExternalSource:{//todo: change to pasteNinja, pasteHTML, etc |
235 | value: function(htmlData, textData){ | 238 | value: function(htmlData, textData){ |
236 | var i=0, | 239 | var i=0, j=0, |
237 | pasteDataObject=null, | 240 | pasteDataObject=null, |
238 | clipboardHelper=this.createClipboardHelper(), | 241 | clipboardHelper=this.createClipboardHelper(), |
239 | pastedElements = null, | 242 | pastedElements = null, |
240 | node = null, | 243 | node = null, |
241 | styles = null, | 244 | styles = null, |
242 | divWrapper = null, | 245 | divWrapper = null, |
243 | spanWrapper = null; | 246 | spanWrapper = null, |
247 | metaEl = null; | ||
244 | 248 | ||
245 | if(htmlData){ | 249 | if(htmlData){ |
250 | |||
246 | //TODO: cleanse HTML | 251 | //TODO: cleanse HTML |
247 | 252 | ||
253 | //TODO: remove all script tags for security | ||
254 | htmlData.replace(/[<script]/g," "); | ||
255 | |||
248 | this.application.ninja.selectedElements.length = 0; | 256 | this.application.ninja.selectedElements.length = 0; |
249 | NJevent("selectionChange", {"elements": this.application.ninja.selectedElements, "isDocument": true} ); | 257 | NJevent("selectionChange", {"elements": this.application.ninja.selectedElements, "isDocument": true} ); |
250 | 258 | ||
251 | clipboardHelper.innerHTML = htmlData;//todo:remove html and body tags | 259 | try{ |
260 | clipboardHelper.innerHTML = htmlData;//this removes html and body tags | ||
261 | } | ||
262 | catch(e){ | ||
263 | console.log(""+e.stack); | ||
264 | } | ||
252 | 265 | ||
253 | while(clipboardHelper.hasChildNodes()){ | 266 | while(clipboardHelper.hasChildNodes()){ |
254 | if(clipboardHelper.lastChild.tagName === "META") { | 267 | if(clipboardHelper.lastChild.tagName === "META") { |