dubtrack / www-dubtrack-fm

GNU General Public License v2.0
123 stars 41 forks source link

chat formatting problem for links with @ symbols #119

Open tmerr opened 9 years ago

tmerr commented 9 years ago

Issue

Type http://@test.com or http://@wat.png into chat. Both render as garbled html.

In firefox, the former displays as @test.com" class="autolink" target="_blank">http://@test.com

The latter displays as @wat.png" class="autolink" target="_blank">@wat.png" alt="http://@wat.png" onload="Dubtrack.room.chat.scollBottomChat();" onerror="Dubtrack.helpers.image.imageError(this, '/assets/images/media/chat_image_load_error.png');Dubtrack.room.chat.scollBottomChat();" />

Cause

See chatItem.view.js lines 12 and 13:

this.model.set( 'message', Dubtrack.helpers.text.convertHtmltoTags( this.model.get('message'), "Dubtrack.room.chat.scollBottomChat();" ));
this.model.set( 'message', Dubtrack.helpers.text.convertAttoLink( this.model.get('message') ));

convertHtmltoTags turns the link into a <a href=.... So far so good. Then convertAttoLink plugs html tags within that and breaks everything.

Possible Fix

Make @mentions delimited by spaces. Something like

convertAttoLink = function(text){
                return text.replace(/(^|[\s\r\n])(@[A-Za-z0-9_.]+)/g, '$1<span class="username-handle">$2&</span>');
            }
Larry1123 commented 8 years ago

http://@:kappa:.com

netux commented 8 years ago

UPDATE: As of right now in beta both links straight up don't work. Only the mention gets converted. In the case of https://test@wat.com the link works correctly.