Skip to content

Fix content validation for existing wiki pages

Markus Koller requested to merge fix-wiki-page-content-validation into master

What does this MR do?

Spotted while doing QA on !36729 (merged):

This new validation didn't work correctly yet because of two reasons:

  • When loading the wiki page in the #update controller action, the content in attributes[:content] won't be initialized which causes content_changed? to return true. Our factory on the other hand sets attributes[:content] as part of its initialization.

    We can fix this by using raw_content instead in content_changed?, and verify this in the specs by reloading the existing page from the wiki.

  • Gollum converts CRLF line endings ("\r\n") to LFs ("\n"), so we also need to do this conversion in WikiPage#content_changed?.

Screenshots

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • [-] Label as security and @ mention @gitlab-com/gl-security/appsec
  • [-] The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • [-] Security reports checked/validated by a reviewer from the AppSec team
Edited by Markus Koller

Merge request reports