Rotonde / beaker

Rotonde client with user account combined(deprecated)
MIT License
205 stars 37 forks source link

fix parsing on @names, dat:// urls #39

Closed cblgh closed 6 years ago

cblgh commented 6 years ago

i just noticed that we have an issue where if i write @neauoire's boat is cool the 's will cause the parser to fail to recognize the name.

there's a similar case with mentioning a dat in a parens as in (dat://ab64573efd68035014d94b83bf034012f415ff4678d3ecf291237e0bdac741b1)
where the beginning parens will cause the parser to fail to recognize the dat link, and if recognized then the last parens will be counted as one of the characters of the string.

i'm writing this issue up instead of fixing it as it's 00:47 already and i have to go to bed!

frozenpandaman commented 6 years ago

the 's will cause the parser to fail to recognize the name.

Same if you have a @username with a period or comma after it.

frozenpandaman commented 6 years ago

OK, here's a quick fix for dealing with single punctuation marks after usernames:

Insert

var wordend = word.substr(word.length-1,word.length).match(/[.,\/#!$%\^&\*;:{}=\-_`~()]/g);
if(wordend){word = word.substr(0,word.length-1);}else{wordend = "";}

after line 101 of scripts/entry.js. And then add a + wordend at the end (inside the parens of course) of the newly-numbered lines 105 and 108. It will then link to their portal: image

This definitely isn't the best way to do it, and doesn't deal with 'ss or multiple punctuation marks following usernames (e.g. cool new project by @username!!!) so I didn't want to send a PR or anything yet. I'm not too familiar with JS, just trying to help out. 😅 Maybe we'll want to m.split on punctuation marks too, or something, instead of just spaces?

neauoire commented 6 years ago

This was just fixed by @cblgh, can anyone double check that it works for all cases?

frozenpandaman commented 6 years ago

@neauoire Seems to work with all regular punctuation as long as there's a space (or nothing, i.e. at the start of the message) directly preceding the username.

image