Disallow @ symbols from post tags

Co-authored-by: Andreas Nedbal <git@pixelde.su>
This commit is contained in:
Karina Kwiatek 2022-01-05 19:48:07 +01:00
parent 683fffd734
commit 023b642bc1
2 changed files with 2 additions and 2 deletions

View File

@ -30,7 +30,7 @@ class ServicesController < ApplicationController
def update def update
service = current_user.services.find(params[:id]) service = current_user.services.find(params[:id])
service.post_tag = params[:service][:post_tag] service.post_tag = params[:service][:post_tag].gsub('@', '')
if service.save if service.save
flash[:success] = "Service updated successfully" flash[:success] = "Service updated successfully"
else else

View File

@ -24,5 +24,5 @@
.col-md-6.mt-2 .col-md-6.mt-2
= bootstrap_form_for(service, as: 'service', url: update_service_path(service)) do |f| = bootstrap_form_for(service, as: 'service', url: update_service_path(service)) do |f|
= f.text_field :post_tag, class: 'form-control', label: 'tag', label_as_placeholder: true, = f.text_field :post_tag, class: 'form-control', label: 'tag', label_as_placeholder: true,
append: f.submit('Update', class: 'btn btn-primary'), maxlength: 20, append: f.submit('Update', class: 'btn btn-primary'), maxlength: 20, pattern: '^[^@]*$',
help: "Automatically append a tag to your shared answers. #{'A # symbol is not automatically prepended.' if service.provider == 'twitter'}" help: "Automatically append a tag to your shared answers. #{'A # symbol is not automatically prepended.' if service.provider == 'twitter'}"