浏览代码

Warn users if github tokens contain invalid chars

Jordi Boggiano 12 年之前
父节点
当前提交
0b94fd209a
共有 1 个文件被更改,包括 3 次插入0 次删除
  1. 3 0
      src/Composer/Factory.php

+ 3 - 0
src/Composer/Factory.php

@@ -199,6 +199,9 @@ class Factory
         // reload oauth token from config if available
         if ($tokens = $config->get('github-oauth')) {
             foreach ($tokens as $domain => $token) {
+                if (!preg_match('{^[a-z0-9]+$}', $token)) {
+                    throw new \UnexpectedValueException('Your github oauth token for '.$domain.' contains invalid characters: "'.$token.'"');
+                }
                 $io->setAuthentication($domain, $token, 'x-oauth-basic');
             }
         }