Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / settings / setting / PhabricatorMonospacedFontSetting.php
blob2a96f5d95faa4f644378dd6adf91c6694bde3e0d
1 <?php
3 final class PhabricatorMonospacedFontSetting
4 extends PhabricatorStringSetting {
6 const SETTINGKEY = 'monospaced';
8 public function getSettingName() {
9 return pht('Monospaced Font');
12 public function getSettingPanelKey() {
13 return PhabricatorDisplayPreferencesSettingsPanel::PANELKEY;
16 protected function getSettingOrder() {
17 return 500;
20 protected function getControlInstructions() {
21 return pht(
22 'You can customize the font used when showing monospaced text, '.
23 'including source code. You should enter a valid CSS font declaration '.
24 'like: `13px Consolas`');
27 public function validateTransactionValue($value) {
28 if (!strlen($value)) {
29 return;
32 $filtered = self::filterMonospacedCSSRule($value);
33 if ($filtered !== $value) {
34 throw new Exception(
35 pht(
36 'Monospaced font value "%s" is unsafe. You may only enter '.
37 'letters, numbers, spaces, commas, periods, hyphens, '.
38 'forward slashes, and double quotes',
39 $value));
43 public static function filterMonospacedCSSRule($monospaced) {
44 // Prevent the user from doing dangerous things.
45 return preg_replace('([^a-z0-9 ,"./-]+)i', '', $monospaced);