]> git.openstreetmap.org Git - rails.git/commitdiff
Limit notes sizes to 2000 characters
authormmd-osm <mmd.osm@gmail.com>
Sat, 3 Nov 2018 17:32:02 +0000 (18:32 +0100)
committermmd-osm <mmd.osm@gmail.com>
Sat, 3 Nov 2018 17:32:02 +0000 (18:32 +0100)
app/models/note_comment.rb
app/views/browse/new_note.html.erb
app/views/browse/note.html.erb

index f8450d0a369625be13158760ae3ae5eb70ec5635..c9caa1b8544c67e53736d887a7c5e6db2d378f79 100644 (file)
@@ -33,7 +33,8 @@ class NoteComment < ActiveRecord::Base
   validates :visible, :inclusion => [true, false]
   validates :author, :associated => true
   validates :event, :inclusion => %w[opened closed reopened commented hidden]
-  validates :body, :format => /\A[^\x00-\x08\x0b-\x0c\x0e-\x1f\x7f\ufffe\uffff]*\z/
+  validates :body, :allow_blank => false, :length => { :maximum => 2000 },
+                   :format => /\A[^\x00-\x08\x0b-\x0c\x0e-\x1f\x7f\ufffe\uffff]*\z/
 
   # Return the comment text
   def body
index f6518daf204b2d5acc8b97c0bfe1332aa02ca930..e8b64b705777a75c77c3fc5cbac914c3d4081c02 100644 (file)
@@ -10,7 +10,7 @@
   <form action="#">
     <input type="hidden" name="lon">
     <input type="hidden" name="lat">
-    <textarea class="comment" name="text" cols="40" rows="10" placeholder="<%= t('javascripts.notes.new.advice') %>"></textarea>
+    <textarea class="comment" name="text" cols="40" rows="10" maxlength="2000" placeholder="<%= t('javascripts.notes.new.advice') %>"></textarea>
     <div class="buttons clearfix">
       <input type="submit" name="add" value="<%= t('javascripts.notes.new.add') %>" disabled="1">
     </div>
index 53ea0759e9f79866bbbfc97dfe416e0b0a1d0e8d..a677a7c14e72684bbb6c776961bd6236d57900f0 100644 (file)
@@ -42,7 +42,7 @@
 
   <% if @note.status == "open" %>
     <form action="#">
-      <textarea class="comment" name="text" cols="40" rows="5"></textarea>
+      <textarea class="comment" name="text" cols="40" rows="5" maxlength="2000"></textarea>
       <div class="buttons clearfix">
         <% if current_user and current_user.moderator? -%>
           <input type="submit" name="hide" value="<%= t('javascripts.notes.show.hide') %>" class="deemphasize" data-note-id="<%= @note.id %>" data-method="DELETE" data-url="<%= note_url(@note, 'json') %>">