From 4f2d7949f03e1c198bc888f2d05f421d35c57e21 Mon Sep 17 00:00:00 2001 From: V3n3RiX Date: Mon, 9 Oct 2017 18:53:29 +0100 Subject: reinit the tree, so we can have metadata --- .../ipython/files/2.1.0-substitute-files.patch | 27 +++++++++ ...n-3.2.1-Don-t-redirect-from-edit-to-files.patch | 55 +++++++++++++++++++ ...nly-redirect-to-editor-for-text-documents.patch | 38 +++++++++++++ .../ipython-3.2.1-set-mime-type-on-files.patch | 35 ++++++++++++ ...et-model-mimetype-even-when-content-False.patch | 64 ++++++++++++++++++++++ 5 files changed, 219 insertions(+) create mode 100644 dev-python/ipython/files/2.1.0-substitute-files.patch create mode 100644 dev-python/ipython/files/ipython-3.2.1-Don-t-redirect-from-edit-to-files.patch create mode 100644 dev-python/ipython/files/ipython-3.2.1-only-redirect-to-editor-for-text-documents.patch create mode 100644 dev-python/ipython/files/ipython-3.2.1-set-mime-type-on-files.patch create mode 100644 dev-python/ipython/files/ipython-3.2.1-set-model-mimetype-even-when-content-False.patch (limited to 'dev-python/ipython/files') diff --git a/dev-python/ipython/files/2.1.0-substitute-files.patch b/dev-python/ipython/files/2.1.0-substitute-files.patch new file mode 100644 index 000000000000..659df39226ac --- /dev/null +++ b/dev-python/ipython/files/2.1.0-substitute-files.patch @@ -0,0 +1,27 @@ +substitute the insource files with these messages +diff --git a/IPython/extensions/octavemagic.py b/IPython/extensions/octavemagic.py +new file mode 100644 +index 0000000..dc93fe4 +--- /dev/null ++++ b/IPython/extensions/octavemagic.py +@@ -0,0 +1,7 @@ ++import warnings ++ ++def load_ipython_extension(ip): ++ msg = ("The octavemagic extension has been moved to oct2py. " ++ "After installing oct2py, you can load octavemagic with the " ++ "following command: '%load_ext oct2py.ipython'.") ++ warnings.warn(msg, Warning, stacklevel=2) +diff --git a/IPython/extensions/rmagic.py b/IPython/extensions/rmagic.py +new file mode 100644 +index 0000000..739e491 +--- /dev/null ++++ b/IPython/extensions/rmagic.py +@@ -0,0 +1,7 @@ ++import warnings ++ ++def load_ipython_extension(ip): ++ msg = ("The rmagic extension has been moved to rpy2. " ++ "After installing rpy2, you can load rmagic with the " ++ "following command: '%load_ext rpy2.ipython'.") ++ warnings.warn(msg, Warning, stacklevel=2) diff --git a/dev-python/ipython/files/ipython-3.2.1-Don-t-redirect-from-edit-to-files.patch b/dev-python/ipython/files/ipython-3.2.1-Don-t-redirect-from-edit-to-files.patch new file mode 100644 index 000000000000..5ec742c34cf8 --- /dev/null +++ b/dev-python/ipython/files/ipython-3.2.1-Don-t-redirect-from-edit-to-files.patch @@ -0,0 +1,55 @@ +Upstream patch to fix +"Maliciously crafted text files in IPython/Jupyter editor". + +http://seclists.org/oss-sec/2015/q3/558 +https://bugs.gentoo.org/show_bug.cgi?id=560708 + + +From 2b835ca6daec2592d9127dc85bf2cdcfb718edf2 Mon Sep 17 00:00:00 2001 +From: Min RK +Date: Mon, 20 Jul 2015 12:11:23 -0700 +Subject: [PATCH 4/4] Don't redirect from /edit/ to /files/ + +show failure to decode, instead +--- + IPython/html/static/edit/js/editor.js | 15 +++------------ + 1 file changed, 3 insertions(+), 12 deletions(-) + +diff --git a/IPython/html/static/edit/js/editor.js b/IPython/html/static/edit/js/editor.js +index dd12ea4..75d65e0 100644 +--- a/IPython/html/static/edit/js/editor.js ++++ b/IPython/html/static/edit/js/editor.js +@@ -90,19 +90,10 @@ function($, + }).catch( + function(error) { + that.events.trigger("file_load_failed.Editor", error); +- if (((error.xhr||{}).responseJSON||{}).reason === 'bad format') { +- window.location = utils.url_path_join( +- that.base_url, +- 'files', +- that.file_path +- ); +- } else { +- console.warn('Error while loading: the error was:') +- console.warn(error) +- } ++ console.warn('Error loading: ', error); + cm.setValue("Error! " + error.message + + "\nSaving disabled.\nSee Console for more details."); +- cm.setOption('readOnly','nocursor') ++ cm.setOption('readOnly','nocursor'); + that.save_enabled = false; + } + ); +@@ -186,7 +177,7 @@ function($, + Editor.prototype._clean_state = function(){ + var clean = this.codemirror.isClean(this.generation); + if (clean === this.clean){ +- return ++ return; + } else { + this.clean = clean; + } +-- +2.4.6 + diff --git a/dev-python/ipython/files/ipython-3.2.1-only-redirect-to-editor-for-text-documents.patch b/dev-python/ipython/files/ipython-3.2.1-only-redirect-to-editor-for-text-documents.patch new file mode 100644 index 000000000000..4b1f7d3686c0 --- /dev/null +++ b/dev-python/ipython/files/ipython-3.2.1-only-redirect-to-editor-for-text-documents.patch @@ -0,0 +1,38 @@ +Upstream patch to fix +"Maliciously crafted text files in IPython/Jupyter editor". + +http://seclists.org/oss-sec/2015/q3/558 +https://bugs.gentoo.org/show_bug.cgi?id=560708 + + +From df24d9153b86863ccfa98bf509704d9304143ce1 Mon Sep 17 00:00:00 2001 +From: Min RK +Date: Mon, 20 Jul 2015 12:11:04 -0700 +Subject: [PATCH 3/4] only redirect to editor for text documents + +treat unidentified mime-types as text +--- + IPython/html/static/tree/js/notebooklist.js | 7 +++++++ + 1 file changed, 7 insertions(+) + +diff --git a/IPython/html/static/tree/js/notebooklist.js b/IPython/html/static/tree/js/notebooklist.js +index 0065143..d8c7b2a 100644 +--- a/IPython/html/static/tree/js/notebooklist.js ++++ b/IPython/html/static/tree/js/notebooklist.js +@@ -532,6 +532,13 @@ define([ + icon = 'running_' + icon; + } + var uri_prefix = NotebookList.uri_prefixes[model.type]; ++ if (model.type === 'file' && ++ model.mimetype && model.mimetype.substr(0,5) !== 'text/' ++ ) { ++ // send text/unidentified files to editor, others go to raw viewer ++ uri_prefix = 'files'; ++ } ++ + item.find(".item_icon").addClass(icon).addClass('icon-fixed-width'); + var link = item.find("a.item_link") + .attr('href', +-- +2.4.6 + diff --git a/dev-python/ipython/files/ipython-3.2.1-set-mime-type-on-files.patch b/dev-python/ipython/files/ipython-3.2.1-set-mime-type-on-files.patch new file mode 100644 index 000000000000..b5d4b5fbd668 --- /dev/null +++ b/dev-python/ipython/files/ipython-3.2.1-set-mime-type-on-files.patch @@ -0,0 +1,35 @@ +Upstream patch to fix +"Maliciously crafted text files in IPython/Jupyter editor". + +http://seclists.org/oss-sec/2015/q3/558 +https://bugs.gentoo.org/show_bug.cgi?id=560708 + + +From d729ce7c2063c0de746a7c2ea39697040d0af5bf Mon Sep 17 00:00:00 2001 +From: Min RK +Date: Mon, 20 Jul 2015 12:10:10 -0700 +Subject: [PATCH 1/4] set mime-type on /files/ + +--- + IPython/html/files/handlers.py | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/IPython/html/files/handlers.py b/IPython/html/files/handlers.py +index 7727d08..b358d94 100644 +--- a/IPython/html/files/handlers.py ++++ b/IPython/html/files/handlers.py +@@ -40,6 +40,11 @@ def get(self, path): + cur_mime = mimetypes.guess_type(name)[0] + if cur_mime is not None: + self.set_header('Content-Type', cur_mime) ++ else: ++ if model['format'] == 'base64': ++ self.set_header('Content-Type', 'application/octet-stream') ++ else: ++ self.set_header('Content-Type', 'text/plain') + + if model['format'] == 'base64': + b64_bytes = model['content'].encode('ascii') +-- +2.4.6 + diff --git a/dev-python/ipython/files/ipython-3.2.1-set-model-mimetype-even-when-content-False.patch b/dev-python/ipython/files/ipython-3.2.1-set-model-mimetype-even-when-content-False.patch new file mode 100644 index 000000000000..a69f746f64c0 --- /dev/null +++ b/dev-python/ipython/files/ipython-3.2.1-set-model-mimetype-even-when-content-False.patch @@ -0,0 +1,64 @@ +Upstream patch to fix +"Maliciously crafted text files in IPython/Jupyter editor". + +http://seclists.org/oss-sec/2015/q3/558 +https://bugs.gentoo.org/show_bug.cgi?id=560708 + + +From 50a1366a8fcfb94671c87199515ebc922882f447 Mon Sep 17 00:00:00 2001 +From: Min RK +Date: Mon, 20 Jul 2015 12:10:25 -0700 +Subject: [PATCH 2/4] set model mimetype, even when content=False + +--- + IPython/html/services/contents/filemanager.py | 12 +++++++----- + IPython/html/services/contents/handlers.py | 3 --- + 2 files changed, 7 insertions(+), 8 deletions(-) + +diff --git a/IPython/html/services/contents/filemanager.py b/IPython/html/services/contents/filemanager.py +index 01ce07b..c869c75 100644 +--- a/IPython/html/services/contents/filemanager.py ++++ b/IPython/html/services/contents/filemanager.py +@@ -277,18 +277,20 @@ def _file_model(self, path, content=True, format=None): + model['type'] = 'file' + + os_path = self._get_os_path(path) ++ model['mimetype'] = mimetypes.guess_type(os_path)[0] + + if content: + content, format = self._read_file(os_path, format) +- default_mime = { +- 'text': 'text/plain', +- 'base64': 'application/octet-stream' +- }[format] ++ if model['mimetype'] is None: ++ default_mime = { ++ 'text': 'text/plain', ++ 'base64': 'application/octet-stream' ++ }[format] ++ model['mimetype'] = default_mime + + model.update( + content=content, + format=format, +- mimetype=mimetypes.guess_type(os_path)[0] or default_mime, + ) + + return model +diff --git a/IPython/html/services/contents/handlers.py b/IPython/html/services/contents/handlers.py +index 5cd849e..d77e70e 100644 +--- a/IPython/html/services/contents/handlers.py ++++ b/IPython/html/services/contents/handlers.py +@@ -52,9 +52,6 @@ def validate_model(model, expect_content): + ) + + maybe_none_keys = ['content', 'format'] +- if model['type'] == 'file': +- # mimetype should be populated only for file models +- maybe_none_keys.append('mimetype') + if expect_content: + errors = [key for key in maybe_none_keys if model[key] is None] + if errors: +-- +2.4.6 + -- cgit v1.2.3