0

I'm trying to clean up a database while running some tests in a bash script, and the following attempt at line continuation is not working:

mysql -e "DELETE FROM test.users WHERE username ="\
            "'<a href=https://localhost>XSS Hack!</a>';"

I get the error

ERROR 1044 (42000): Access denied for user 'web'@'localhost' to database ''<a href=https://localhost>XSS Hack!</a>';'

The command works fine if I run it on a single line.

1
  • @SeanBright That works, thanks! So I guess we can always use an implicit line continuation inside a string? Commented Jul 12, 2018 at 20:10

1 Answer 1

1

The backslash escapes the newline, but the whitespace at the beginning of the next line still acts as a word delimiter. So the command becomes equivalent to:

mysql -e "DELETE FROM test.users WHERE username =" "'<a href=https://localhost>XSS Hack!</a>';"

If you end a line in the middle of a string, you don't need to escape the newline. MySQL doesn't mind newlines in queries, either. So you can simply write:

mysql -e "DELETE FROM test.users WHERE username =
          '<a href=https://localhost>XSS Hack!</a>';"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.