There are some subtle points like if you want to escape '%s' (the string specifier) %%s is enough because the first % escapes the second and thus 's' becomes the literal character, no longer part of a format specifier.
In Perl, we can use \Q and \E to "quote" a string in a pattern so that any special characters are automatically escape. Using "\Q[[test]]+\E" would be the same as "\[\[test\[\]\+". Is there something similar in Lua pattern matching?
Not in the core string library, with the minor exception of the "plain substring" flag to string.find(). That's a feature of that specific function however, not of the quoting styles.
The string lib is deliberately kept simple for space reasons (the pattern matching isn't even basic regular expressions). Anything more complicated is usually dealt with by dropping in LPEG, written by one of the Lua architects. Since WoW addons can't load third-party libs, we're out of luck there.