Merge remote-tracking branch 'origin/QA_4_0' into QA_4_0

This commit is contained in:
Weblate 2013-05-02 10:29:21 +02:00
commit b8e1faf839
2 changed files with 31 additions and 3 deletions

View File

@ -244,9 +244,9 @@ class Advisor
);
// Replaces external Links with PMA_linkURL() generated links
$rule['recommendation'] = preg_replace(
'#href=("|\')(https?://[^\1]+)\1#ie',
'\'href="\' . PMA_linkURL("\2") . \'"\'',
$rule['recommendation'] = preg_replace_callback(
'#href=("|\')(https?://[^\1]+)\1#i',
array($this, '_replaceLinkURL'),
$rule['recommendation']
);
break;
@ -255,6 +255,18 @@ class Advisor
$this->runResult[$type][] = $rule;
}
/**
* Callback for wrapping links with PMA_linkURL
*
* @param array $matches List of matched elements form preg_replace_callback
*
* @return Replacement value
*/
private function _replaceLinkURL($matches)
{
return 'href="' . PMA_linkURL($matches[2]) . '"';
}
/**
* Callback for evaluating fired() condition.
*

View File

@ -178,6 +178,22 @@ class Advisor_test extends PHPUnit_Framework_TestCase
array(),
'Failed formatting string for rule \'Failure\'. PHP threw following error: Use of undefined constant fsafdsa - assumed \'fsafdsa\'',
),
array(
array(
'justification' => 'Version string (%s) | value',
'name' => 'Distribution',
'issue' => 'official MySQL binaries.',
'recommendation' => 'See <a href="http://phpma.org/">web</a>',
),
array(
'justification' => 'Version string (0)',
'name' => 'Distribution',
'issue' => 'official MySQL binaries.',
'recommendation' => 'See <a href="./url.php?url=http%3A%2F%2Fphpma.org%2F&amp;lang=en&amp;token=token">web</a>',
'id' => 'Distribution'
),
null,
),
);
}
}