plots2 icon indicating copy to clipboard operation
plots2 copied to clipboard

"redirect" power tags to non-existent pages should not be creatable

Open ryzokuken opened this issue 9 years ago • 4 comments

Hi, this is a first-timers-only issue. This means we've worked to make it more legible to folks who either haven't contributed to our codebase before, or even folks who haven't contributed to open source before.

If that's you, we're interested in helping you take the first step and can answer questions and help you out as you do. Note that we're especially interested in contributions from people from groups under-represented in free and open source software!

If you have contributed before, consider leaving this one for someone new, and looking through our general help wanted issues. Thanks!


Prerequisites

You don't really need to know anything in advance in order to tackle this issue. However, a little understanding about Ruby and how classes work with/without Ruby would certainly help you crack this issue.

Get started with Ruby:

  1. https://www.codecademy.com/learn/ruby
  2. http://rubylearning.com/
  3. https://www.codeschool.com/learn/ruby
  4. http://tryruby.org/levels/1/challenges/0
  5. https://www.ruby-lang.org/en/documentation/quickstart/
  6. https://learnrubythehardway.org/

The Problem

Currently, adding a tag like redirect:pagename redirects to https://publiclab.org/wiki/pagename (as a pattern, using power tags)

However, if a page with the url pagename doesn't exist, it still lets you create the tag. @jywarren has captured this issue in a test here, in a separate branch:

https://github.com/publiclab/plots2/pull/1294/files#diff-887412fe6b629256bdbefa512d3515c7R184

The Solution

We should add a check to the node.can_tag() method to check if:

  1. it is a redirect tag
  2. it points at an existing page (with DrupalNode.where(slug: tagname.split(':')[1]).length > 0

https://github.com/publiclab/plots2/blob/master/app/models/drupal_node.rb#L736-L754

And it should respond with a reasonable message like "that page doesn't exist!"

elsif tagname.split(':')[0] == 'redirect' && DrupalNode.where(slug: tagname.split(':')[1]).length <= 0
  return errors ? "Page doesn't exist" : false
end

Steps to Fix

  • [ ] claim this issue with a comment here, below, and ask any clarifying questions you need
  • [ ] set up a repository locally following the README instructions, and make sure that all tests pass
  • [ ] try to fix the issue following the steps above, but even before you're done, you can:
  • [ ] commit your changes and start a pull request (see contributing to Public Lab software) but mark it as "in progress" if you have questions or if you haven't finished
  • [ ] alert someone via the developers list (see below) to have your pull request merged. This may take a few extra steps depending on when you do it, but we'll help you out!

Please email the developers list (see https://publiclab.org/developers) if you have questions!

ryzokuken avatar Feb 28 '17 14:02 ryzokuken

I would like to have a go at this

Ellimist22 avatar Mar 01 '17 03:03 Ellimist22

@Ellimist22 Sure! In case you face any issues, please feel free to ask over here or in our Gitter channels. Goodluck!

ryzokuken avatar Mar 01 '17 14:03 ryzokuken

Hi, has this issue been solved? Otherwise I would like to work on this.

saurabh-sikchi avatar Mar 05 '17 10:03 saurabh-sikchi

Hi, I believe @Ellimist22 has submitted a fix in #1309 -- thanks! You can find other issues on https://github.com/publiclab/plots2/projects/2 and https://github.com/publiclab/plots2/labels/help-wanted

jywarren avatar Mar 06 '17 22:03 jywarren