File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -221,6 +221,8 @@ var TAG_STYLES = {
221221 em : 'font-style:italic;font-weight:bold'
222222} ;
223223
224+ var PROTOCOLS = [ 'http:' , 'https:' , 'mailto' ] ;
225+
224226var STRIP_TAGS = new RegExp ( '</?(' + Object . keys ( TAG_STYLES ) . join ( '|' ) + ')( [^>]*)?/?>' , 'g' ) ;
225227
226228util . plainText = function ( _str ) {
@@ -252,7 +254,14 @@ function convertToSVG(_str){
252254 if ( tag === 'a' ) {
253255 if ( close ) return '</a>' ;
254256 else if ( extra . substr ( 0 , 4 ) . toLowerCase ( ) !== 'href' ) return '<a>' ;
255- else return '<a xlink:show="new" xlink:href' + extra . substr ( 4 ) + '>' ;
257+ else {
258+ var dummyAnchor = document . createElement ( 'a' ) ;
259+ dummyAnchor . href = extra . split ( 'href=' ) [ 1 ] . replace ( / [ " ' ] / g, '' ) ;
260+
261+ if ( PROTOCOLS . indexOf ( dummyAnchor . protocol ) === - 1 ) return '<a>' ;
262+
263+ return '<a xlink:show="new" xlink:href' + extra . substr ( 4 ) + '>' ;
264+ }
256265 }
257266 else if ( tag === 'br' ) return '<br>' ;
258267 else if ( close ) {
You can’t perform that action at this time.
0 commit comments