Maybe i'm doing something wrong, but i;ve installed on a fresh drupal 7 this module. Created a field, no error messages, but when adding a new piece of content, i keep getting "is not a valid SoundCloud URL'.

I openend 'soundcloudfield.module' and did found this function:

// function soundcloudfield_field_validate($entity_type, $entity, $field, $instance, $langcode, $items, &$errors) {
function soundcloudfield_field_validate($obj_type, $object, $field, $instance, $langcode, &$items, &$errors) {
if ($field['type'] == 'soundcloud') {
foreach ($items as $delta => $item) {
if (!empty($item['url']) && !preg_match('@^http://soundcloud\.com/([^"\&]+)@i', $item['url'], $matches)) {
$errors[$field['field_name']][$langcode][$delta][] = array(
'error' => 'soundcloudfield_invalid_url',
'message' => t('%url is not a valid SoundCloud URL.', array('%url' => $item['url'])),
);
}
}
}
}

The problem with pasting from the soundcloud url is, that it copies 'https', and then the regulair expression fails. Maybe it's an option to change it so both url pass the test. Like "https://soundcloud.com/vaughan-1-1/fletch-vaughan-the-two-best" and "http://soundcloud.com/vaughan-1-1/fletch-vaughan-the-two-best, both would be 'ok'.

Or are there problems with allowing https- links?

Thanks for your time, wonderfull module!

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Anonymous’s picture

Confirmed. Just came across this issue myself and indeed, when I changed line 47 in 'soundcloudfield.module' from

if (!empty($item['url']) && !preg_match('@^http://soundcloud\.com/([^"\&]+)@i', $item['url'], $matches)) {

to

if (!empty($item['url']) && !preg_match('@^https://soundcloud\.com/([^"\&]+)@i', $item['url'], $matches)) {

it worked again. Would like to know if there are any issues with changing this line.

SoniaWilk

Anonymous’s picture

Update....I noticed that there are 2 places where one can "share" links to sound files on SoundCloud. One uses "https" and one uses "http". No idea what makes the difference, or why both are used. I will have no control over what users will copy/paste, so I'll need the code to allow for both versions.

I'm not a programmer...can someone please provide the code that will allow for "http" and "https"? I don't know if a wildcard is needed, or simply "if ____ or ____ then...". I just don't know how to get there. :)

Please and thanks!!

SoniaWilk

valdo’s picture

Status: Active » Needs review
FileSize
857 bytes

The regular expression should be this: '@^https?://soundcloud\.com/([^"\&]+)@i'

I just replaced "http" with "https?", which allows optional "s" in the protocol name. Patch for this change is attached, please review and commit. Thanks!

Anonymous’s picture

This works - Thanks valdo! I tried both a link that was http:// and https:// - all is golden.

valdo’s picture

Priority: Normal » Critical
Status: Needs review » Reviewed & tested by the community

Attila please commit, thanks. I have marked this bug as critical because SoundCloud's sharing link by default is with https://, so this module is not usable at the moment because of this bug.

attila.fekete’s picture

Assigned: Unassigned » attila.fekete
Status: Reviewed & tested by the community » Fixed

Thank you!
Commited to 7.x-1.x-dev.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

  • Commit cd0b780 on 7.x-1.x, 8.x-1.x by attila.fekete:
    Issue #1865514 by Xenophon, SoniaWilk, valdo: Fixed HTTPS bug