From the course: Writing Secure Code in iOS by Infosec

Unlock this course with a free trial

Join today to access over 24,900 courses taught by industry experts.

Special characters, part 1

Special characters, part 1

- Let's go take a look at special characters. Now, there are a number of different kinds of special characters, but specifically, let's look at the string literals in Swift. What's the risk? Well, special characters can sometimes be misinterpreted as commands. And common examples would be single quote, double quote, dot, forward and backslash. You'd want to probably search for and exclude characters that you know could be harmful in your string. For example, if I saw ../ that could be used in a directory traversal attack in a website. Special characters, the only thing is that they are language-specific. They're context-specific. There's no one-size-fits-all for unsafe characters 'cause what works for this won't work for that, works for the other. It depends on the language and the platform of the target. In Swift, we escape special characters. We make them literal with a backslash. Here are Swift's string literal special characters. Now, Swift has string in character types. They are…

Contents