From 2624f82787ee6357bde238a8e334b21eced91fc0 Mon Sep 17 00:00:00 2001 From: MinRK Date: Tue, 14 Oct 2014 12:30:58 -0700 Subject: [PATCH 1/2] set contentType='application/json' instead of skipping straight to headers avoids jQuery's crazy JSONP detection on `=.*??`, which was triggered because it assumed the contentType was unspecified, and thus should be guessed based on content. --- IPython/html/static/notebook/js/notebook.js | 4 ++-- IPython/html/static/tree/js/notebooklist.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/IPython/html/static/notebook/js/notebook.js b/IPython/html/static/notebook/js/notebook.js index 8f03eb3e0..d84bbd35d 100644 --- a/IPython/html/static/notebook/js/notebook.js +++ b/IPython/html/static/notebook/js/notebook.js @@ -1941,7 +1941,7 @@ define([ cache : false, type : "PUT", data : JSON.stringify(model), - headers : {'Content-Type': 'application/json'}, + contentType: 'application/json', dataType : "json", success : $.proxy(this.save_notebook_success, this, start), error : $.proxy(this.save_notebook_error, this) @@ -2158,7 +2158,7 @@ define([ type : "PATCH", data : JSON.stringify(data), dataType: "json", - headers : {'Content-Type': 'application/json'}, + contentType: 'application/json', success : $.proxy(that.rename_success, this), error : $.proxy(that.rename_error, this) }; diff --git a/IPython/html/static/tree/js/notebooklist.js b/IPython/html/static/tree/js/notebooklist.js index d74a154f0..7f526d788 100644 --- a/IPython/html/static/tree/js/notebooklist.js +++ b/IPython/html/static/tree/js/notebooklist.js @@ -434,7 +434,7 @@ define([ cache : false, type : 'PUT', data : JSON.stringify(model), - headers : {'Content-Type': content_type}, + contentType: content_type, success : function (data, status, xhr) { item.removeClass('new-file'); that.add_link(model, item); From 7c2083aa60d3e0baee1bb8de8c460a89eba05a0b Mon Sep 17 00:00:00 2001 From: MinRK Date: Tue, 14 Oct 2014 16:13:53 -0700 Subject: [PATCH 2/2] test saving with problematic cell contents --- IPython/html/tests/notebook/save.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/IPython/html/tests/notebook/save.js b/IPython/html/tests/notebook/save.js index e1f67bc9f..b59d12c97 100644 --- a/IPython/html/tests/notebook/save.js +++ b/IPython/html/tests/notebook/save.js @@ -8,7 +8,9 @@ casper.notebook_test(function () { // This causes no actual problems, but will break string comparison. var nbname = "has#hash and space and unicø∂e.ipynb"; - this.evaluate(function (nbname) { + this.append_cell("s = '??'", 'code'); + + this.thenEvaluate(function (nbname) { require(['base/js/events'], function (events) { IPython.notebook.notebook_name = nbname; IPython._save_success = IPython._save_failed = false;