Skip to content
Snippets Groups Projects
Unverified Commit 3128820f authored by Henne Vogelsang's avatar Henne Vogelsang Committed by GitHub
Browse files

Merge pull request #6050 from hennevogel/bugfix/nullbytes

Fix xml output for comments
parents a344d8cd 8ca9200b
No related branches found
No related tags found
No related merge requests found
......@@ -19,7 +19,8 @@ Bugfixes
========
Frontend:
*
* Do not allow null characters in comments
* Prevent creation of a request with an ID attribute
Backend:
* avoid wipebinaries in locked projects
......
......@@ -7,6 +7,8 @@ class Comment < ApplicationRecord
validates :body, :commentable, :user, presence: true
# FIXME: this probably should be MEDIUMTEXT(16MB) instead of text (64KB)
validates :body, length: { maximum: 65_535 }
validates :body, format: { with: /\A[^\u0000]*\Z/,
message: 'must not contain null characters' }
validate :validate_parent_id
......@@ -64,6 +66,7 @@ class Comment < ApplicationRecord
def to_xml(builder)
attrs = { who: user, when: created_at, id: id }
attrs[:parent] = parent_id if parent_id
body.delete!("\u0000")
builder.comment_(attrs) do
builder.text(body)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment