Prevent empty attributes in permalinks

Closes #5714