Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion src/Models/Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ class Service extends BaseSystemModel
protected $fillable = ['name', 'label', 'description', 'is_active', 'type', 'config'];

protected $rules = [
'name' => 'regex:/(^[A-Za-z0-9_\-]+$)+/'
'name' => 'regex:/(^[A-Za-z0-9_\-]+$)+/',
'label' => 'string|max:80',
'description' => 'string|max:255'
];

protected $validationMessages = [
Expand Down Expand Up @@ -80,6 +82,28 @@ public function disableRelated()
// allow config
}

/**
* Sanitize the label attribute to prevent XSS attacks
* Strips all HTML tags before storing
*
* @param string $value
*/
public function setLabelAttribute($value)
{
$this->attributes['label'] = strip_tags($value);
}

/**
* Sanitize the description attribute to prevent XSS attacks
* Strips all HTML tags before storing
*
* @param string $value
*/
public function setDescriptionAttribute($value)
{
$this->attributes['description'] = strip_tags($value);
}

public static function boot()
{
parent::boot();
Expand Down