This is an automated email from the ASF dual-hosted git repository. garren pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/couchdb-fauxton.git
The following commit(s) were added to refs/heads/master by this push: new 0edc46a Encode view attachment URL (#1055) 0edc46a is described below commit 0edc46a4871425237b29dd3b9a486470caa34e9e Author: Antonio Maranhao <30349380+antonio-maran...@users.noreply.github.com> AuthorDate: Wed Feb 7 06:40:45 2018 -0500 Encode view attachment URL (#1055) --- .../documents/doc-editor/__tests__/doc-editor.components.test.js | 8 ++++---- app/addons/documents/doc-editor/components.js | 7 +++---- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/app/addons/documents/doc-editor/__tests__/doc-editor.components.test.js b/app/addons/documents/doc-editor/__tests__/doc-editor.components.test.js index 178eb47..8f314ba 100644 --- a/app/addons/documents/doc-editor/__tests__/doc-editor.components.test.js +++ b/app/addons/documents/doc-editor/__tests__/doc-editor.components.test.js @@ -34,7 +34,7 @@ const docJSON = { }; const docWithAttachmentsJSON = { - _id: '_design/test-doc', + _id: '_design/test#doc', _rev: '12345', blah: { whatever: { @@ -42,7 +42,7 @@ const docWithAttachmentsJSON = { } }, _attachments: { - "one.png": { + "one%2F.png": { "content-type": "images/png", "length": 100 }, @@ -53,7 +53,7 @@ const docWithAttachmentsJSON = { } }; -const database = new Databases.Model({ id: 'id' }); +const database = new Databases.Model({ id: 'a/special?db' }); describe('DocEditorController', () => { @@ -137,7 +137,7 @@ describe('DocEditorController', () => { const $attachmentNode = el.find('.view-attachments-section .dropdown-menu li'); const attachmentURLactual = $attachmentNode.find('a').first().prop('href'); - assert.equal(attachmentURLactual, '../../id/_design/test-doc/one.png'); + assert.equal(attachmentURLactual, '../../a%2Fspecial%3Fdb/_design%2Ftest%23doc/one%252F.png'); }); it.skip('setting deleteDocModal=true in store shows modal', () => { diff --git a/app/addons/documents/doc-editor/components.js b/app/addons/documents/doc-editor/components.js index 8f98824..72441e2 100644 --- a/app/addons/documents/doc-editor/components.js +++ b/app/addons/documents/doc-editor/components.js @@ -11,7 +11,6 @@ // the License. import FauxtonAPI from "../../../core/api"; -import app from "../../../app"; import PropTypes from 'prop-types'; import React from "react"; import { Dropdown, MenuItem } from "react-bootstrap"; @@ -216,11 +215,11 @@ class AttachmentsPanelButton extends React.Component { }; getAttachmentList = () => { - var db = this.props.doc.database.get('id'); - var doc = this.props.doc.get('_id'); + const db = encodeURIComponent(this.props.doc.database.get('id')); + const doc = encodeURIComponent(this.props.doc.get('_id')); return _.map(this.props.doc.get('_attachments'), function (item, filename) { - var url = FauxtonAPI.urls('document', 'attachment', db, doc, app.utils.safeURLName(filename)); + const url = FauxtonAPI.urls('document', 'attachment', db, doc, encodeURIComponent(filename)); return ( <MenuItem key={filename} href={url} target="_blank" data-bypass="true"> <strong>{filename}</strong> -- To stop receiving notification emails like this one, please contact gar...@apache.org.