suyati / line-control

A Light Weight HTML5 Text Editor designed as a JQuery Plugin
Other
124 stars 90 forks source link

Incorrect URL regex pattern #77

Open jacobcsmith opened 7 years ago

jacobcsmith commented 7 years ago

The RegEx pattern validating URLs does not ensure the text starts with a valid URL. This can be used to insert a javascript function and is potentially a XSS vulnerability. For example the following URL is accepted:

javascript:alert('XSS')/*http://www.google.com*/

In the onSave function the following pattern is used: var urlPattern = /(http|ftp|https):\/\/[\w-]+(\.[\w-]+)+([\w.,@?^=%&:\/~+#-]*[\w@?^=%&\/~+#-])?/i;

I believe the correct pattern should be: var urlPattern = /^(http|ftp|https):\/\/[\w-]+(\.[\w-]+)+([\w.,@?^=%&:\/~+#-]*[\w@?^=%&\/~+#-])?/i;