Skip to content

Commit

Permalink
Merge branch 't/13030' into major
Browse files Browse the repository at this point in the history
  • Loading branch information
Reinmar committed Apr 7, 2015
2 parents aba11da + 74ecd60 commit b0d867d
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 6 deletions.
2 changes: 1 addition & 1 deletion plugins/filetools/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@
evt.cancel();
} else {
data.fileName = response.fileName;
data.url = encodeURI( response.url );
data.url = response.url;
}
} catch ( err ) {
// Response parsing error.
Expand Down
Binary file added tests/_assets/le na.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions tests/plugins/filetools/fileloader.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,30 @@
wait();
},

'test upload response not encoded (#13030)': function() {
var loader = new FileLoader( editorMock, pngBase64, 'na me.png' ),
observer = observeEvents( loader );

createXMLHttpRequestMock( [ 'progress', 'load' ], {
responseText: '{"fileName":"na me2.png","uploaded":1,"url":"http:\/\/url\/na me2.png"}'
} );

resumeAfter( loader, 'uploaded', function() {
observer.assert( [
'uploading[uploading,na me.png,0/82/82,-,data:image/png;base64,-]',
'update[uploading,na me.png,0/82/82,-,data:image/png;base64,-]',
'update[uploading,na me.png,41/82/82,-,data:image/png;base64,-]',
'uploaded[uploaded,na me2.png,82/82/82,-,data:image/png;base64,http://url/na me2.png]',
'update[uploaded,na me2.png,82/82/82,-,data:image/png;base64,http://url/na me2.png]' ] );
}, 3 );

loader.upload( 'http:\/\/url\/' );

assert.areSame( 'http:\/\/url\/', loader.uploadUrl );

wait();
},

'test loadAndUpload': function() {
var loader = new FileLoader( editorMock, testFile ),
observer = observeEvents( loader );
Expand Down
13 changes: 8 additions & 5 deletions tests/plugins/uploadwidget/manual/_helpers/xhr.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,20 @@ window.XMLHttpRequest = function() {
}
// If file is loaded call onload.
else {
clearInterval( interval );
xhr.status = 200;
xhr.responseText = JSON.stringify( {
var responseData = {
fileName: formData.getFileName(),
uploaded: 1,
url: '\/' + basePath + '_assets\/lena.jpg',
error: {
number: 201,
message: ''
}
} );
};
CKEDITOR.tools.extend( responseData, XMLHttpRequest.responseData, true );

clearInterval( interval );
xhr.status = 200;
xhr.responseText = JSON.stringify( responseData );
onload();
}
}, 400 );
Expand All @@ -73,4 +76,4 @@ window.XMLHttpRequest = function() {
this.onabort();
}
};
};
};
13 changes: 13 additions & 0 deletions tests/plugins/uploadwidget/manual/noserverresponseencoding.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<div id="editor"></div>

<script>
CKEDITOR.replace( 'editor', {
imageUploadUrl: 'http://sub.ckeditor.dev/'
} );

// We are going to overwrite server response to have encoded one.
var basePath = bender.config.tests[ bender.testData.group ].basePath;
XMLHttpRequest.responseData = {
url: '\/' + basePath + '_assets\/le%20na.jpg'
};
</script>
12 changes: 12 additions & 0 deletions tests/plugins/uploadwidget/manual/noserverresponseencoding.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
@bender-tags: 4.5.0, tc
@bender-ui: collapsed
@bender-ckeditor-plugins: wysiwygarea, image2, uploadimage, toolbar
@bender-include: _helpers/xhr.js

**Ignore this test unless running Bender 0.2.3+.**

1. Drag and drop some image into editable.

**Expected result:** Image should be uploaded and you should see *Lena* **upside down**.

**Unexpected result:** After upload no *Lena* is shown.

0 comments on commit b0d867d

Please sign in to comment.