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!
Comment | File | Size | Author |
---|---|---|---|
#3 | allow-https-in-soundcloud-url-1865514-3.patch | 857 bytes | valdo |
Comments
Comment #1
Anonymous (not verified) CreditAttribution: Anonymous commentedConfirmed. 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
Comment #2
Anonymous (not verified) CreditAttribution: Anonymous commentedUpdate....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
Comment #3
valdo CreditAttribution: valdo commentedThe 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!
Comment #4
Anonymous (not verified) CreditAttribution: Anonymous commentedThis works - Thanks valdo! I tried both a link that was http:// and https:// - all is golden.
Comment #5
valdo CreditAttribution: valdo commentedAttila 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.
Comment #6
attila.fekete CreditAttribution: attila.fekete commentedThank you!
Commited to 7.x-1.x-dev.