Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F96678557
PhabricatorMonospacedFontSetting.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, Dec 29, 18:31
Size
1 KB
Mime Type
text/x-php
Expires
Tue, Dec 31, 18:31 (2 d)
Engine
blob
Format
Raw Data
Handle
23210425
Attached To
rPH Phabricator
PhabricatorMonospacedFontSetting.php
View Options
<?php
final
class
PhabricatorMonospacedFontSetting
extends
PhabricatorStringSetting
{
const
SETTINGKEY
=
'monospaced'
;
public
function
getSettingName
()
{
return
pht
(
'Monospaced Font'
);
}
public
function
getSettingPanelKey
()
{
return
PhabricatorDisplayPreferencesSettingsPanel
::
PANELKEY
;
}
protected
function
getSettingOrder
()
{
return
500
;
}
protected
function
getControlInstructions
()
{
return
pht
(
'You can customize the font used when showing monospaced text, '
.
'including source code. You should enter a valid CSS font declaration '
.
'like: `13px Consolas`'
);
}
public
function
validateTransactionValue
(
$value
)
{
if
(!
strlen
(
$value
))
{
return
;
}
$filtered
=
self
::
filterMonospacedCSSRule
(
$value
);
if
(
$filtered
!==
$value
)
{
throw
new
Exception
(
pht
(
'Monospaced font value "%s" is unsafe. You may only enter '
.
'letters, numbers, spaces, commas, periods, hyphens, '
.
'forward slashes, and double quotes'
,
$value
));
}
}
public
static
function
filterMonospacedCSSRule
(
$monospaced
)
{
// Prevent the user from doing dangerous things.
return
preg_replace
(
'([^a-z0-9 ,"./-]+)i'
,
''
,
$monospaced
);
}
}
Event Timeline
Log In to Comment