tenderlove / rails_autolink

The auto_link function from Rails
MIT License
588 stars 91 forks source link

Update test suite for rails 7 #72

Closed ramhoj closed 2 years ago

ramhoj commented 2 years ago

Summary

This PR addresses https://github.com/tenderlove/rails_autolink/issues/69 by updating the test suite to fix failing specs when running the test suite under rails 7.

Why

To make new contributions easier.

How

We’re delegating escaping and sanitisation to ActionView#sanitize. The last commit is 6 years old and the rails dependency is specified as > 3.1 so it’s only natural that the test suite was no longer up-to-date.

Current behaviour on Rails 7.0.3.1:

  1. Self-closing tags no longer has / before >.
  2. & is escaped as %amp;.
  3. Save part of malicious content is rendered.
  4. target attribute is rendered before href.
  5. + is escaped in mailto link.

Notice that 2. illustrates that auto linking emails with & behave differently than specified in the original test suite. This commit does not change the behaviour but documents the difference in behaviour. It is possible that this is a regression that should be addressed.

Notes

This PR is simular to https://github.com/tenderlove/rails_autolink/pull/66 and if https://github.com/tenderlove/rails_autolink/pull/66 were merged first the diff of this PR would be smaller. In this PR we also addressing some warnings and are not adding the rails-dom-testing dependency.