@@ -95,8 +95,11 @@ util.convertToTspans = function(_context, _callback) {
9595 visibility : 'visible' ,
9696 'white-space' : 'pre'
9797 } ) ;
98+
9899 result = _context . appendSVG ( converted ) ;
100+
99101 if ( ! result ) _context . text ( str ) ;
102+
100103 if ( _context . select ( 'a' ) . size ( ) ) {
101104 // at least in Chrome, pointer-events does not seem
102105 // to be honored in children of <text> elements
@@ -246,6 +249,7 @@ function convertToSVG(_str) {
246249 var match = d . match ( / < ( \/ ? ) ( [ ^ > ] * ) \s * ( .* ) > / i) ,
247250 tag = match && match [ 2 ] . toLowerCase ( ) ,
248251 style = TAG_STYLES [ tag ] ;
252+
249253 if ( style !== undefined ) {
250254 var close = match [ 1 ] ,
251255 extra = match [ 3 ] ,
@@ -263,12 +267,18 @@ function convertToSVG(_str) {
263267 if ( close ) return '</a>' ;
264268 else if ( extra . substr ( 0 , 4 ) . toLowerCase ( ) !== 'href' ) return '<a>' ;
265269 else {
266- var dummyAnchor = document . createElement ( 'a' ) ;
267- dummyAnchor . href = extra . substr ( 4 ) . replace ( / [ " ' = ] / g, '' ) ;
270+ // remove quotes, leading '=', replace '&' with '&'
271+ var href = extra . substr ( 4 )
272+ . replace ( / [ " ' ] / g, '' )
273+ . replace ( / = / , '' )
274+ . replace ( / & / g, '&' ) ;
268275
276+ // check protocol
277+ var dummyAnchor = document . createElement ( 'a' ) ;
278+ dummyAnchor . href = href ;
269279 if ( PROTOCOLS . indexOf ( dummyAnchor . protocol ) === - 1 ) return '<a>' ;
270280
271- return '<a xlink:show="new" xlink:href' + extra . substr ( 4 ) + '>' ;
281+ return '<a xlink:show="new" xlink:href=" ' + href + '" >' ;
272282 }
273283 }
274284 else if ( tag === 'br' ) return '<br>' ;
0 commit comments