I set up a project on my site and was shocked and dismayed to find that the "home page" has to be a "valid url"! This is not very drupalish, is it? It should ideally permit either an absolute path on the site (/page/whatever) or a relative path on the site (page/whatever) or an external url (method://path). The current approach neglects sites which are accessible from multiple URLs and like it that way, and sites which are currently in testing (if I am testing on localhost and move to a real site, now I've got to go change the home page of every drupal project.)

Should be a pretty easy patch (he said without looking at the code at all) but I'm working on another project right now...

Comments

aclight’s picture

The code that does URL validation on the project form page is in project.inc and looks like this:

function project_project_validate(&$node) {
...
  // Make sure all URL fields actually contain URLs.
  foreach (array('homepage', 'changelog', 'cvs', 'demo') as $uri) {
    if ($node->$uri && !preg_match('/^(http|https|ftp):\/\//i', $node->$uri)) {
      form_set_error($uri, t('!field is not a valid URL.', array('!field' => t(ucfirst($uri)))));
    }
  }
...

This does pretty much the same thing as the drupal function valid_url() does.

Changing the code to do what you want to do would require either writing a fair amount of code to do validation of the URL or just not doing any real validation at all, which could be a security risk. Additionally, d.o doesn't seem to have any reason to allow project pages to be somewhere else on the site, so this kind of validation is necessary.

The only semi-reasonable way I can think of to handle this would be to add a setting in the projects administration page that has 2 options, one of which is the way validation is done now and one of which is essentially no validation.

AC

aclight’s picture

Status: Active » Closed (duplicate)

I'm marking this as a duplicate of http://drupal.org/node/25679 to help consolidate issues