Skip to content

Commit 9848bfb

Browse files
Prevent leading hash in chat channel field
1 parent 634307c commit 9848bfb

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

html-templates/projects/projectEdit.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
</div>
5252
<div class="form-group">
5353
<label for="field-chat-channel">{_ "Chat Channel/Hashtag"}:</label>
54-
<input name="ChatChannel" id="field-chat-channel" class="form-control" placeholder="train_schedule_analyzer" value="{refill field=ChatChannel default=$Project->ChatChannel}"/>
54+
<input name="ChatChannel" id="field-chat-channel" class="form-control" placeholder="train_schedule_analyzer" value="{refill field=ChatChannel default=$Project->ChatChannel}" pattern="[A-Za-z0-9_]+" title="Hash tag containing only letters, numbers, or underscores without leading #"/>
5555
</div>
5656
<div class="form-group">
5757
<label for="topicTagsInput">{_ 'Topic Tags'}:</label>

php-classes/Laddr/ProjectsRequestHandler.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Laddr;
44

5+
use ActiveRecord;
56
use Emergence\People\User;
67
use Tag;
78
use TagItem;
@@ -227,6 +228,15 @@ public static function handleUpdatesRequest(Project $Project)
227228
]);
228229
}
229230

231+
protected static function applyRecordDelta(ActiveRecord $Project, $requestData)
232+
{
233+
if (!empty($requestData['ChatChannel']) && $requestData['ChatChannel'][0] == '#') {
234+
$requestData['ChatChannel'] = substr($requestData['ChatChannel'], 1);
235+
}
236+
237+
return parent::applyRecordDelta($Project, $requestData);
238+
}
239+
230240
public static function onRecordSaved(\ActiveRecord $Project, $requestData)
231241
{
232242
// assign tags

0 commit comments

Comments
 (0)