Skip to content

Commit

Permalink
Merge pull request #5870 from eduardoj/fix_comment_output_in_osc
Browse files Browse the repository at this point in the history
Fix xml output  for comments
  • Loading branch information
hennevogel committed Sep 18, 2018
2 parents 7e4e30b + 8b19a36 commit 1338289
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/api/app/models/comment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -69,6 +71,7 @@ def to_xml(builder, include_commentable = false)
attrs['project'] = commentable.project if commentable.is_a?(Package)
end
attrs[:parent] = parent_id if parent_id
body.delete!("\u0000")

builder.comment_(attrs) do
builder.text(body)
Expand Down

0 comments on commit 1338289

Please sign in to comment.