File tree 1 file changed +10
-1
lines changed
Filter options
1 file changed +10
-1
lines changed
Original file line number Diff line number Diff line change @@ -221,6 +221,8 @@ var TAG_STYLES = {
221
221
em : 'font-style:italic;font-weight:bold'
222
222
} ;
223
223
224
+ var PROTOCOLS = [ 'http:' , 'https:' , 'mailto' ] ;
225
+
224
226
var STRIP_TAGS = new RegExp ( '</?(' + Object . keys ( TAG_STYLES ) . join ( '|' ) + ')( [^>]*)?/?>' , 'g' ) ;
225
227
226
228
util . plainText = function ( _str ) {
@@ -252,7 +254,14 @@ function convertToSVG(_str){
252
254
if ( tag === 'a' ) {
253
255
if ( close ) return '</a>' ;
254
256
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
+ }
256
265
}
257
266
else if ( tag === 'br' ) return '<br>' ;
258
267
else if ( close ) {
You can’t perform that action at this time.
0 commit comments