From 911fe1c89e7257a092f0dfc08f03093967dbe8f7 Mon Sep 17 00:00:00 2001 From: technoweenie Date: Tue, 16 Jan 2007 14:40:01 +0000 Subject: [PATCH] RESTRICT hyphens as a possible separator for permalink styles. [Chris Wanstrath] git-svn-id: http://svn.techno-weenie.net/projects/mephisto/trunk@2697 567b1171-46fb-0310-a4c9-b4bef9110e78 --- CHANGELOG | 2 +- app/models/site.rb | 2 +- test/unit/site_permalink_test.rb | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 06c4d353..0feeb316 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,6 @@ * SVN * -* Allow hyphens as an allowed separator for permalink styles. [Chris Wanstrath] +* RESTRICT hyphens as a possible separator for permalink styles. [Chris Wanstrath] * Initial article/asset assignment support. Perfect for podcasting. diff --git a/app/models/site.rb b/app/models/site.rb index 1d9c44b0..95e70edf 100644 --- a/app/models/site.rb +++ b/app/models/site.rb @@ -212,7 +212,7 @@ def permalink_variable?(var) def check_permalink_style permalink_style.sub! /^\//, '' permalink_style.sub! /\/$/, '' - pieces = permalink_style.split(Regexp.new('/|-')) + pieces = permalink_style.split('/') errors.add :permalink_style, 'cannot have blank paths' if pieces.any?(&:blank?) pieces.each do |p| errors.add :permalink_style, "cannot contain '#{p}' variable" unless p.blank? || permalink_variable_format?(p).nil? || permalink_variable?(p) diff --git a/test/unit/site_permalink_test.rb b/test/unit/site_permalink_test.rb index 3262464d..f35ac897 100644 --- a/test/unit/site_permalink_test.rb +++ b/test/unit/site_permalink_test.rb @@ -43,9 +43,9 @@ def setup assert_equal "cannot contain ':foo' variable", @site.errors.on(:permalink_style) end - specify "should recongize hyphens as token separators" do + specify "should not recongize hyphens as token separators" do @site.permalink_style = ':id-:permalink' - assert_valid @site + assert !@site.valid? end end