diff --git a/CHANGES.md b/CHANGES.md
index 12c78cf164c..16739a73212 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -9,6 +9,7 @@ Fixed Issues:
* [#13434](http://dev.ckeditor.com/ticket/13434): [IE8-9] Fixed: One drag&drop operation may affect following ones.
* [#13129](http://dev.ckeditor.com/ticket/13129) Fixed: Block widget blurred after drop followed by undo.
* [#13468](http://dev.ckeditor.com/ticket/13468): [IE] Fixed: Binding drag&drop `dataTransfer` does not work if `text` data was set in the meantime.
+* [#13419](http://dev.ckeditor.com/ticket/13419): Fixed: [Auto Link](http://ckeditor.com/addon/autolink) plugin does not encode double quotes in URLs.
## CKEditor 4.5.1
diff --git a/plugins/autolink/plugin.js b/plugins/autolink/plugin.js
index 56852682fe0..f5a1933e2c3 100644
--- a/plugins/autolink/plugin.js
+++ b/plugins/autolink/plugin.js
@@ -3,34 +3,40 @@
* For licensing, see LICENSE.md or http://ckeditor.com/license
*/
-'use strict';
-
-CKEDITOR.plugins.add( 'autolink', {
- requires: 'clipboard',
-
- init: function( editor ) {
- editor.on( 'paste', function( evt ) {
- var data = evt.data.dataValue;
-
- if ( evt.data.dataTransfer.getTransferType( editor ) == CKEDITOR.DATA_TRANSFER_INTERNAL ) {
- return;
- }
-
- // If we found "<" it means that most likely there's some tag and we don't want to touch it.
- if ( data.indexOf( '<' ) > -1 ) {
- return;
- }
-
- // Regex by Imme Emosol.
- data = data.replace( /^(https?|ftp):\/\/(-\.)?([^\s\/?\.#-]+\.?)+(\/[^\s]*)?[^\s\.,]$/ig , '$&' );
-
- // If link was discovered, change the type to 'html'. This is important e.g. when pasting plain text in Chrome
- // where real type is correctly recognized.
- if ( data != evt.data.dataValue ) {
- evt.data.type = 'html';
- }
-
- evt.data.dataValue = data;
- } );
- }
-} );
\ No newline at end of file
+( function() {
+ 'use strict';
+
+ // Regex by Imme Emosol.
+ var validUrlRegex = /^(https?|ftp):\/\/(-\.)?([^\s\/?\.#-]+\.?)+(\/[^\s]*)?[^\s\.,]$/ig,
+ doubleQuoteRegex = /"/g;
+
+ CKEDITOR.plugins.add( 'autolink', {
+ requires: 'clipboard',
+
+ init: function( editor ) {
+ editor.on( 'paste', function( evt ) {
+ var data = evt.data.dataValue;
+
+ if ( evt.data.dataTransfer.getTransferType( editor ) == CKEDITOR.DATA_TRANSFER_INTERNAL ) {
+ return;
+ }
+
+ // If we found "<" it means that most likely there's some tag and we don't want to touch it.
+ if ( data.indexOf( '<' ) > -1 ) {
+ return;
+ }
+
+ // #13419
+ data = data.replace( validUrlRegex , '$&' );
+
+ // If link was discovered, change the type to 'html'. This is important e.g. when pasting plain text in Chrome
+ // where real type is correctly recognized.
+ if ( data != evt.data.dataValue ) {
+ evt.data.type = 'html';
+ }
+
+ evt.data.dataValue = data;
+ } );
+ }
+ } );
+} )();
\ No newline at end of file
diff --git a/tests/plugins/autolink/autolink.js b/tests/plugins/autolink/autolink.js
index 04cbca2bcb2..43cc89d34aa 100644
--- a/tests/plugins/autolink/autolink.js
+++ b/tests/plugins/autolink/autolink.js
@@ -47,6 +47,14 @@ bender.test( {
}
},
+ // #13419
+ 'test link with quotation marks': function() {
+ var pastedText = 'https://foo.bar/?bam="bom"',
+ expected = 'https://foo.bar/?bam="bom"';
+
+ assertPasteEvent( this.editor, { dataValue: pastedText }, { dataValue: expected, type: 'html' } );
+ },
+
'test link with text after': function() {
var pastedText = 'https://placekitten.com/g/210/300 nope';