Changeset 28969


Ignore:
Timestamp:
Jul 6, 2014, 4:05:05 PM (10 years ago)
Author:
mistic100
Message:

improves regexes parsing plugins metadata

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/include/languages.class.php

    r26998 r28969  
    159159          $plg_data = implode( '', file($path.'/common.lang.php') );
    160160
    161           if ( preg_match("|Language Name: (.*)|", $plg_data, $val) )
     161          if (preg_match("|Language Name:\\s*(.+)|", $plg_data, $val))
    162162          {
    163163            $language['name'] = trim( $val[1] );
    164164            $language['name'] = convert_charset($language['name'], 'utf-8', $target_charset);
    165165          }
    166           if (preg_match("|Version: (.*)|", $plg_data, $val))
     166          if (preg_match("|Version:\\s*([\\w.-]+)|", $plg_data, $val))
    167167          {
    168168            $language['version'] = trim($val[1]);
    169169          }
    170           if ( preg_match("|Language URI: (.*)|", $plg_data, $val) )
     170          if (preg_match("|Language URI:\\s*(https?:\\/\\/.+)|", $plg_data, $val))
    171171          {
    172172            $language['uri'] = trim($val[1]);
    173173          }
    174           if ( preg_match("|Author: (.*)|", $plg_data, $val) )
     174          if (preg_match("|Author:\\s*(.+)|", $plg_data, $val))
    175175          {
    176176            $language['author'] = trim($val[1]);
    177177          }
    178           if ( preg_match("|Author URI: (.*)|", $plg_data, $val) )
     178          if (preg_match("|Author URI:\\s*(https?:\\/\\/.+)|", $plg_data, $val))
    179179          {
    180180            $language['author uri'] = trim($val[1]);
     
    185185            if (is_numeric($extension)) $language['extension'] = $extension;
    186186          }
     187
    187188          // IMPORTANT SECURITY !
    188189          $language = array_map('htmlspecialchars', $language);
  • trunk/admin/include/plugins.class.php

    r28695 r28969  
    258258          $plg_data = file_get_contents($path.'/main.inc.php', null, null, 0, 2048);
    259259
    260           if ( preg_match("|Plugin Name: (.*)|", $plg_data, $val) )
     260          if (preg_match("|Plugin Name:\\s*(.+)|", $plg_data, $val))
    261261          {
    262262            $plugin['name'] = trim( $val[1] );
    263263          }
    264           if (preg_match("|Version: (.*)|", $plg_data, $val))
     264          if (preg_match("|Version:\\s*([\\w.-]+)|", $plg_data, $val))
    265265          {
    266266            $plugin['version'] = trim($val[1]);
    267267          }
    268           if ( preg_match("|Plugin URI: (.*)|", $plg_data, $val) )
     268          if (preg_match("|Plugin URI:\\s*(https?:\\/\\/.+)|", $plg_data, $val))
    269269          {
    270270            $plugin['uri'] = trim($val[1]);
     
    274274            $plugin['description'] = trim($desc);
    275275          }
    276           elseif ( preg_match("|Description: (.*)|", $plg_data, $val) )
     276          elseif (preg_match("|Description:\\s*(.+)|", $plg_data, $val))
    277277          {
    278278            $plugin['description'] = trim($val[1]);
    279279          }
    280           if ( preg_match("|Author: (.*)|", $plg_data, $val) )
     280          if (preg_match("|Author:\\s*(.+)|", $plg_data, $val))
    281281          {
    282282            $plugin['author'] = trim($val[1]);
    283283          }
    284           if ( preg_match("|Author URI: (.*)|", $plg_data, $val) )
     284          if (preg_match("|Author URI:\\s*(https?:\\/\\/.+)|", $plg_data, $val))
    285285          {
    286286            $plugin['author uri'] = trim($val[1]);
     
    291291            if (is_numeric($extension)) $plugin['extension'] = $extension;
    292292          }
     293
    293294          // IMPORTANT SECURITY !
    294295          $plugin = array_map('htmlspecialchars', $plugin);
  • trunk/admin/include/themes.class.php

    r28651 r28969  
    376376            'mobile' => false,
    377377            );
    378           $theme_data = implode( '', file($path.'/themeconf.inc.php') );
    379 
    380           if ( preg_match("|Theme Name: (.*)|", $theme_data, $val) )
     378          $theme_data = implode('', file($path.'/themeconf.inc.php'));
     379
     380          if (preg_match("|Theme Name:\\s*(.+)|", $theme_data, $val))
    381381          {
    382382            $theme['name'] = trim( $val[1] );
    383383          }
    384           if (preg_match("|Version: (.*)|", $theme_data, $val))
     384          if (preg_match("|Version:\\s*([\\w.-]+)|", $theme_data, $val))
    385385          {
    386386            $theme['version'] = trim($val[1]);
    387387          }
    388           if ( preg_match("|Theme URI: (.*)|", $theme_data, $val) )
     388          if (preg_match("|Theme URI:\\s*(https?:\\/\\/.+)|", $theme_data, $val))
    389389          {
    390390            $theme['uri'] = trim($val[1]);
     
    394394            $theme['description'] = trim($desc);
    395395          }
    396           elseif ( preg_match("|Description: (.*)|", $theme_data, $val) )
     396          elseif (preg_match("|Description:\\s*(.+)|", $theme_data, $val))
    397397          {
    398398            $theme['description'] = trim($val[1]);
    399399          }
    400           if ( preg_match("|Author: (.*)|", $theme_data, $val) )
     400          if (preg_match("|Author:\\s*(.+)|", $theme_data, $val))
    401401          {
    402402            $theme['author'] = trim($val[1]);
    403403          }
    404           if ( preg_match("|Author URI: (.*)|", $theme_data, $val) )
     404          if (preg_match("|Author URI:\\s*(https?:\\/\\/.+)|", $theme_data, $val))
    405405          {
    406406            $theme['author uri'] = trim($val[1]);
  • trunk/include/functions_plugins.inc.php

    r28651 r28969  
    381381      if ($i < 2) continue; // first lines are typically "<?php" and "/*"
    382382
    383       if (preg_match('#Version: ([\\w.-]+)#', $line, $matches))
     383      if (preg_match('/Version:\\s*([\\w.-]+)/', $line, $matches))
    384384      {
    385385        $fs_version = $matches[1];
Note: See TracChangeset for help on using the changeset viewer.