Strip leading and trailing slug punctuation.

Reported by [BhaelOchon](http://meta.discourse.org/users/BhaelOchon) in meta thread ["Not all trailing hyphens trimmed from topic URLs"](http://meta.discourse.org/t/not-all-trailing-hyphens-trimmed-from-topic-urls/1555).