I'm creating a link to a page based on the name the user gave that page. However, the link is unclickable if the name is a zero-width space.
How can I stop users from giving pages unclickable names? I'd like to allow Unicode characters if possible.
The names are being entered into the database through a Django form, and the HTML link is being built in jQuery. Django complains if the name is a regular space, but accepts a zero-width space.
var linkText1 = 'foo', linkText2 = '\u200b';
$('#ex1')
.append($('<a>')
.text(linkText1)
.attr('href', 'javascript:alert("clicked.")'));
$('#ex2')
.append($('<a>')
.text(linkText2)
.attr('href', 'javascript:alert("clicked.")'));
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<p id="ex1">Example 1 </p>
<p id="ex2">Example 2 </p>