Skip to content

Commit

Permalink
Merge pull request TryGhost#2036 from xuduo35/0.4-maintenance
Browse files Browse the repository at this point in the history
bug caused by unidecode's bug
  • Loading branch information
ErisDS committed Jan 27, 2014
2 parents d05b764 + 1d1caad commit 5e97bcb
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions core/server/models/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,13 @@ ghostBookshelf.Model = ghostBookshelf.Model.extend({
});
};

slug = base.trim();

// Remove non ascii characters
slug = unidecode(slug);

// Remove URL reserved chars: `:/?#[]@!$&'()*+,;=` as well as `\%<>|^~£"`
slug = base.trim().replace(/[:\/\?#\[\]@!$&'()*+,;=\\%<>\|\^~£"]/g, '')
slug = slug.replace(/[:\/\?#\[\]@!$&'()*+,;=\\%<>\|\^~£"]/g, '')
// Replace dots and spaces with a dash
.replace(/(\s|\.)/g, '-')
// Convert 2 or more dashes into a single dash
Expand All @@ -224,8 +229,7 @@ ghostBookshelf.Model = ghostBookshelf.Model.extend({

// Remove trailing hyphen
slug = slug.charAt(slug.length - 1) === '-' ? slug.substr(0, slug.length - 1) : slug;
// Remove non ascii characters
slug = unidecode(slug);

// Check the filtered slug doesn't match any of the reserved keywords
slug = /^(ghost|ghost\-admin|admin|wp\-admin|wp\-login|dashboard|logout|login|signin|signup|signout|register|archive|archives|category|categories|tag|tags|page|pages|post|posts|user|users|rss)$/g
.test(slug) ? slug + '-post' : slug;
Expand Down

0 comments on commit 5e97bcb

Please sign in to comment.