]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Merge commit 'refs/merge-requests/1900' of git://gitorious.org/statusnet/mainline...
authorBrion Vibber <brion@pobox.com>
Mon, 2 Nov 2009 18:16:06 +0000 (10:16 -0800)
committerBrion Vibber <brion@pobox.com>
Mon, 2 Nov 2009 18:16:06 +0000 (10:16 -0800)
1  2 
lib/util.php

diff --combined lib/util.php
index ed7e10f6bd465b5bdaa350413b008022a9ed6a82,00696583eea7b1d14dcd24fb0332110dd8aa877a..bf7282858abaea20dd4430c4d18780f77d5f9359
@@@ -422,7 -422,7 +422,7 @@@ function common_render_text($text
  function common_replace_urls_callback($text, $callback, $notice_id = null) {
      // Start off with a regex
      $regex = '#'.
 -    '(?:^|[\s\(\)\[\]\{\}\\\'\\\";]+)(?![\@\!\#])'.
 +    '(?:^|[\s\<\>\(\)\[\]\{\}\\\'\\\";]+)(?![\@\!\#])'.
      '('.
          '(?:'.
              '(?:'. //Known protocols
          ')'.
          '(?:'.
              '(?:\:\d+)?'. //:port
 -            '(?:/[\pN\pL$\[\]\,\!\(\)\.\:\-\_\+\/\=\&\;\%\~\*\$\+\'\"@]*)?'. // /path
 -            '(?:\?[\pN\pL\$\[\]\,\!\(\)\.\:\-\_\+\/\=\&\;\%\~\*\$\+\'\"@\/]*)?'. // ?query string
 -            '(?:\#[\pN\pL$\[\]\,\!\(\)\.\:\-\_\+\/\=\&\;\%\~\*\$\+\'\"\@/\?\#]*)?'. // #fragment
 +            '(?:/[\pN\pL$\,\!\(\)\.\:\-\_\+\/\=\&\;\%\~\*\$\+\'@]*)?'. // /path
 +            '(?:\?[\pN\pL\$\,\!\(\)\.\:\-\_\+\/\=\&\;\%\~\*\$\+\'@\/]*)?'. // ?query string
 +            '(?:\#[\pN\pL$\,\!\(\)\.\:\-\_\+\/\=\&\;\%\~\*\$\+\'\@/\?\#]*)?'. // #fragment
          ')(?<![\?\.\,\#\,])'.
      ')'.
      '#ixu';
@@@ -480,10 -480,6 +480,10 @@@ function callback_helper($matches, $cal
          array(
              'left'=>'{',
              'right'=>'}'
 +        ),
 +        array(
 +            'left'=>'<',
 +            'right'=>'>'
          )
      );
      $cannotEndWith=array('.','?',',','#');
@@@ -785,18 -781,12 +785,18 @@@ function common_path($relative, $ssl=fa
          if (is_string(common_config('site', 'sslserver')) &&
              mb_strlen(common_config('site', 'sslserver')) > 0) {
              $serverpart = common_config('site', 'sslserver');
 -        } else {
 +        } else if (common_config('site', 'server')) {
              $serverpart = common_config('site', 'server');
 +        } else {
 +            common_log(LOG_ERR, 'Site Sever not configured, unable to determine site name.');
          }
      } else {
          $proto = 'http';
 -        $serverpart = common_config('site', 'server');
 +        if (common_config('site', 'server')) {
 +            $serverpart = common_config('site', 'server');
 +        } else {
 +            common_log(LOG_ERR, 'Site Sever not configured, unable to determine site name.');
 +        }
      }
  
      return $proto.'://'.$serverpart.'/'.$pathpart.$relative;
@@@ -1370,9 -1360,28 +1370,28 @@@ function common_memcache(
      }
  }
  
+ function common_license_terms($uri)
+ {
+     if(preg_match('/creativecommons.org\/licenses\/([^\/]+)/', $uri, $matches)) {
+         return explode('-',$matches[1]);
+     }
+     return array($uri);
+ }
  function common_compatible_license($from, $to)
  {
+     $from_terms = common_license_terms($from);
+     // public domain and cc-by are compatible with everything
+     if(count($from_terms) == 1 && ($from_terms[0] == 'publicdomain' || $from_terms[0] == 'by')) {
+         return true;
+     }
+     $to_terms = common_license_terms($to);
+     // sa is compatible across versions. IANAL
+     if(in_array('sa',$from_terms) || in_array('sa',$to_terms)) {
+         return count(array_diff($from_terms, $to_terms)) == 0;
+     }
      // XXX: better compatibility check needed here!
+     // Should at least normalise URIs
      return ($from == $to);
  }