librefm-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Librefm-commits] [1192] Discard any MusicBrainz ID submissions not of t


From: Clint Adams
Subject: [Librefm-commits] [1192] Discard any MusicBrainz ID submissions not of the form a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11 to avoid additional database pollution .
Date: Tue, 05 May 2009 00:44:44 +0000

Revision: 1192
          http://svn.sv.gnu.org/viewvc/?view=rev&root=librefm&revision=1192
Author:   clint
Date:     2009-05-05 00:44:43 +0000 (Tue, 05 May 2009)
Log Message:
-----------
Discard any MusicBrainz ID submissions not of the form 
a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11 to avoid additional database pollution.

Modified Paths:
--------------
    trunk/gnukebox/nowplaying/1.2/index.php
    trunk/gnukebox/scrobble-utils.php
    trunk/gnukebox/submissions/1.2/index.php

Modified: trunk/gnukebox/nowplaying/1.2/index.php
===================================================================
--- trunk/gnukebox/nowplaying/1.2/index.php     2009-05-05 00:03:20 UTC (rev 
1191)
+++ trunk/gnukebox/nowplaying/1.2/index.php     2009-05-05 00:44:43 UTC (rev 
1192)
@@ -46,11 +46,7 @@
        $expires = time() + 250; //Expire in 5 minutes if we don't know the 
track length
 }
 
-if(isset($_POST['m'])) {
-       $mbid = $mdb2->quote($_POST['m'], "text");
-} else {
-       $mbid = 'NULL';
-}
+$mbid = validateMBID($_POST['m']);
 
 createArtistIfNew($artist);
 if($album != 'NULL') {

Modified: trunk/gnukebox/scrobble-utils.php
===================================================================
--- trunk/gnukebox/scrobble-utils.php   2009-05-05 00:03:20 UTC (rev 1191)
+++ trunk/gnukebox/scrobble-utils.php   2009-05-05 00:44:43 UTC (rev 1192)
@@ -210,4 +210,16 @@
         return $image;
 }
 
+function validateMBID ($input) {
+
+if(isset($input) {
+       $input = strtolower(rtrim($input));
+       
if(preg_match('/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/',
 $input)) {
+               return $mdb2->quote($input, "text");
+       } else {
+               return 'NULL'
+       }
+} else {
+       return 'NULL';
+}
 ?>

Modified: trunk/gnukebox/submissions/1.2/index.php
===================================================================
--- trunk/gnukebox/submissions/1.2/index.php    2009-05-05 00:03:20 UTC (rev 
1191)
+++ trunk/gnukebox/submissions/1.2/index.php    2009-05-05 00:44:43 UTC (rev 
1192)
@@ -83,11 +83,9 @@
                date_default_timezone_set("UTC");
                $time = strtotime($_POST['i'][$i]);
        }
-       if(isset($_POST['m'][$i])) {
-               $mbid = $mdb2->quote(rtrim($_POST['m'][$i]), "text");
-       } else {
-               $mbid = 'NULL';
-       }
+
+       $mbid = validateMBID($_POST['m']);
+
        if(isset($_POST['o'][$i])) {
                $source = $mdb2->quote($_POST['o'][$i], "text");
        } else {





reply via email to

[Prev in Thread] Current Thread [Next in Thread]