Permalink
Browse files

Merge pull request #74 from codyrobbins/master

Fixes for #72 and #73
  • Loading branch information...
2 parents b5dcd9a + d63eb6f commit 47349b9411983da5109b367ca784c3981015c606 @vmg vmg committed Nov 26, 2011
Showing with 27 additions and 2 deletions.
  1. +2 −2 ext/redcarpet/autolink.c
  2. +25 −0 test/redcarpet_test.rb
@@ -24,9 +24,9 @@
int
sd_autolink_issafe(const uint8_t *link, size_t link_len)
{
- static const size_t valid_uris_count = 4;
+ static const size_t valid_uris_count = 5;
static const char *valid_uris[] = {
- "http://", "https://", "ftp://", "mailto://"
+ "/", "http://", "https://", "ftp://", "mailto:"
};
size_t i;
@@ -92,6 +92,31 @@ def test_that_safelink_flag_works
html_equal "<p>[IRC](irc://chat.freenode.org/#freenode)</p>\n", rd
end
+ def test_that_safelink_flag_allows_relative_urls
+ rd = render_with(@rndr[:safe_links], "[Relative](/tanoku/redcarpet)")
+ html_equal "<p>[Relative](/tanoku/redcarpet)</p>\n", rd
+ end
+
+ def test_that_safelink_flag_allows_http_urls
+ rd = render_with(@rndr[:safe_links], "[HTTP](http://github.com/tanoku/redcarpet)")
+ html_equal "<p>[HTTP](http://github.com/tanoku/redcarpet)</p>\n", rd
+ end
+
+ def test_that_safelink_flag_allows_https_urls
+ rd = render_with(@rndr[:safe_links], "[HTTPS](https://github.com/tanoku/redcarpet)")
+ html_equal "<p>[HTTPS](https://github.com/tanoku/redcarpet)</p>\n", rd
+ end
+
+ def test_that_safelink_flag_allows_ftp_urls
+ rd = render_with(@rndr[:safe_links], "[FTP](http://ftp.mozilla.org/pub/mozilla.org/)")
+ html_equal "<p>[FTP](http://ftp.mozilla.org/pub/mozilla.org/)</p>\n", rd
+ end
+
+ def test_that_safelink_flag_allows_mailto_urls
+ rd = render_with(@rndr[:safe_links], "[Email](mailto:test@example.com)")
+ html_equal "<p>[Email](mailto:test@example.com)</p>\n", rd
+ end
+
end
class MarkdownTest < Test::Unit::TestCase

0 comments on commit 47349b9

Please sign in to comment.