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() {
20 protected function getControlInstructions() {
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)) {
32 $filtered = self
::filterMonospacedCSSRule($value);
33 if ($filtered !== $value) {
36 'Monospaced font value "%s" is unsafe. You may only enter '.
37 'letters, numbers, spaces, commas, periods, hyphens, '.
38 'forward slashes, and double quotes',
43 public static function filterMonospacedCSSRule($monospaced) {
44 // Prevent the user from doing dangerous things.
45 return preg_replace('([^a-z0-9 ,"./-]+)i', '', $monospaced);