sivaraj28may / pagedown

Automatically exported from code.google.com/p/pagedown
Other
0 stars 0 forks source link

sanitizeHtml() stripping images with apostrophes in URL - Regex modification required #83

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
======================================

1. Attempting to insert an image with an apostrophe in the URL e.g:

https://d3sn47bls4ur42.cloudfront.net/20150028/a6021aa6-0500-2d55-b9e6-d14ce9cc7
73c/parisian-austrian-jeweller's-shop-wrecked-after-outbreak-of-war.jpg

The function sanitizeHtml in Markdown.Santitizer.js uses a regex pattern which 
does not permit apostrophes. This causes images with such URLs to be stripped 
from preview.

What is the expected output? What do you see instead?
=====================================================

Preview HTML stripped of images.

What version of the product are you using? On what operating system?
====================================================================

Tested against regex as in use today (2015/01/28), commit 2a8c75ce3fb5 I 
believe (though the full product version I am using is older)

Please provide any additional information below.
===============================================

Changing img_white variable to below fixes the issue (apostrophe included after 
0-9 in regex pattern).

var img_white = 
/^(<img\ssrc="(https?:\/\/|\/)[-A-Za-z0-9'+&@#\/%?=~_|!:,.;\(\)*[\]$]+"(\swidth=
"\d{1,3}")?(\sheight="\d{1,3}")?(\salt="[^"<>]*")?(\stitle="[^"<>]*")?\s?\/?>)$/
i;

Original issue reported on code.google.com by gareth.r...@gmail.com on 28 Jan 2015 at 12:30