Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

External links containing an @ at symbol currently parse as public lab usernames. #7675

Closed
emilyashley opened this issue Mar 17, 2020 · 24 comments
Labels
help wanted requires help by anyone willing to contribute Ruby ws used by staff for internal tracking
Milestone

Comments

@emilyashley
Copy link
Member

emilyashley commented Mar 17, 2020

Scenario:
When inserting an external link on a public lab post
And the link contains an @
Then it should parse as part of the URL and not a link to a public lab username

Screenshot from @joyofsoy:
Screen Shot 2020-03-17 at 3 47 42 PM

Here's an example link to test from the screenshot above: https://medium.com/@erinargyle/working-during-covid-19-how-to-be-good-at-video-meetings-57f49fdb8dcd

A current workaround is to use a site like bit.ly to obfuscate the links, but we'd ideally fix this. Thanks @joyofsoy for reporting! 🎉

@emilyashley
Copy link
Member Author

emilyashley commented Mar 17, 2020

Notes from Jeff:

@jywarren : I think we need to change the @______ pattern matcher to not find the pattern inside of links. The pattern matcher is here:

FINDER = /([^`\w]|^)\@([\w-]+)/

Here's a demo of the pattern match failing based on Joe's original links; it has to be modified to NOT recognize usernames inside of URLs: https://rubular.com/r/HsxxuTG8zG0zSL
Screen Shot 2020-03-17 at 3 57 45 PM

@Tlazypanda
Copy link
Collaborator

@emilyashley can I work on this?

@jywarren
Copy link
Member

@Tlazypanda that would be super, thank you!!!

@emilyashley emilyashley added the ws used by staff for internal tracking label Apr 21, 2020
@ebarry
Copy link
Member

ebarry commented Apr 29, 2020

Hi @Tlazypanda , did you have a chance to try out any changes using this expression editor? https://rubular.com/r/HsxxuTG8zG0zSL Seems like a little game, to try and adjust how the '@NAMEs' are recognized on our site but not when there is a '/' on either side.

@Tlazypanda
Copy link
Collaborator

Hey @ebarry I am so sorry totally forgot about this issue while working on other issues ...is it alright if I take it up after some days since my university examinations are going on 😅

@ebarry
Copy link
Member

ebarry commented Apr 29, 2020

Of course!!! Good luck on exams!!!

@jywarren jywarren added this to the Editor milestone May 5, 2020
@jywarren jywarren added help wanted requires help by anyone willing to contribute Ruby labels May 5, 2020
@stale stale bot added the stale label Oct 7, 2020
@publiclab publiclab deleted a comment from stale bot Oct 8, 2020
@stale stale bot removed the stale label Oct 8, 2020
@gauravahlawat81
Copy link
Member

gauravahlawat81 commented Dec 17, 2020

([^`\w]|^)(?<!\/)\@([\w-]+)\b(?!\/)

Seems to be working correctly.Can you please confirm if this regex is correct or not @ebarry ?

Screenshot from 2020-12-17 23-24-02

@gauravahlawat81
Copy link
Member

@jywarren Can you confirm this ?

@ebarry
Copy link
Member

ebarry commented Jan 5, 2021

I wish i could confirm either way but i'm not familiar with regex, sorry for my delayed response, and THANK YOU for working on this!

@jywarren
Copy link
Member

jywarren commented Jan 5, 2021

Works perfectly! https://rubular.com/r/jfKfgjdqi00qy4

image

This can now be inserted at constants.rb -- it'd make a good first-timers-only issue too!

This has been marked as a good candidate for becoming a first-timers-only issue like these, meaning that it's simple, self-contained, and with some extra formatting, could be a great entry point for a new contributor. If you're familiar enough with this code, please consider reformatting or reposting it as a first-timers-only issue, and then ping @publiclab/reviewers to get it labelled. Or, if this is not your first time, try to solve it yourself!


@ebarry
Copy link
Member

ebarry commented Jan 5, 2021 via email

@gauravahlawat81
Copy link
Member

gauravahlawat81 commented Jan 6, 2021

@ebarry Could you please convert it into FTO, so that others can solve it ? Thanks!

@cesswairimu
Copy link
Collaborator

great job @gauravahlawat81 I can do that for you...or maybe you would like to try and convert this yourself?...I am happy to help where stuck..what do you think?

@gauravahlawat81
Copy link
Member

Yeah sure, I would like to convert it by myself. How do I do that ?

@gauravahlawat81
Copy link
Member

Should I create a new issue or edit this one ?

@cesswairimu
Copy link
Collaborator

Great 🎉, yeah creating a new one would be simpler, when you click on new issue here https://github.com/publiclab/plots2/issues/new/choose select the First timer Only Issue and it will prefill a template...after this line where you have **Update** the file [$FILENAME]($BRANCH_URL) in the `$REPO` repository (press the little pen Icon) and edit the line as shown below. indicate the file that needs to be changed and the changes needed... Give it a title and that should be all

@gauravahlawat81
Copy link
Member

Alright, thanks @cesswairimu , I will give it a try!

@gauravahlawat81
Copy link
Member

@cesswairimu How do I generate the diff ?

@cesswairimu
Copy link
Collaborator

Not sure if there is another way of doing it...the way I do it is using the first-timer-bot
So with this approach what you do is navigate to the file that you want to edit in this case I believe is https://github.com/publiclab/plots2/blob/main/config/initializers/constants.rb and click on the edit button(pencil icon), make the changes that are needed, then the text-box below this Create a new branch for this commit and start a pull request edit that and make sure it starts with first-timers- then click commit changes...

after that you should see your issue created here https://github.com/publiclab/plots2/issues/ with author as first-timer-bot
more documentation on this is here if this doesn't make sense

@gauravahlawat81
Copy link
Member

I have created the issue, though I had to use a different approach. Please see if everything is fine there, and if something needs to be changed, do let me know.

@cesswairimu
Copy link
Collaborator

The issue is perfect..thanks again

@cesswairimu
Copy link
Collaborator

FTO link #8947

@cesswairimu
Copy link
Collaborator

Fixed in #8972 Thanks everyone

@ebarry
Copy link
Member

ebarry commented Jan 8, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted requires help by anyone willing to contribute Ruby ws used by staff for internal tracking
Projects
None yet
Development

No branches or pull requests

6 participants