You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by GitBox <gi...@apache.org> on 2018/02/07 11:40:49 UTC

[GitHub] garrensmith closed pull request #1055: Encode view attachment URL

garrensmith closed pull request #1055: Encode view attachment URL
URL: https://github.com/apache/couchdb-fauxton/pull/1055
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

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 178eb475b..8f314ba5d 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 8f9882400..72441e278 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>


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services