Correct square brackets handling in strings