Ticket #56 (closed defect: fixed)

Opened 4 years ago

Last modified 4 years ago

Newlines get unescaped on their way to the database.

Reported by: schuler.steffen Owned by: scott
Priority: critical Milestone: awkpaste
Component: awkbot Version: 1.0
Keywords: Cc:

Description

As reported by steffen schuler:


If one pastes code with the literal ``\n'' inside the code or
in the header, then the pasted output is different.

Reproduction Steps

  1. Navigate to  http://awkpaste.blisted.org/
  2. Enter the following paste:
    # An escaped linefeed
    print "\n"
    
    # An escaped escape and an n.
    print "\\\n"
    
    # An escaped carriage return
    print "\r"
    
    # An escaped esacpe and an r.
    print "\\r"
    
    # escaped escape
    print "\\"
    
    # End of line that's escaped.
    print "This string is waaaaaaay too large for me to possibly be able " \
          "to fit it in a single line"
    
    # Some accidental backslashes: \\
    # Four backslashes and an n: \\\\n
    
  3. Observe output.
  4. Click paste-id link at top left corner of page.

Expected

The paste output from the paste-id link is the same as that returned by the form submission.

Observed

The text \n is translated into a newline in the paste output.

Additionally, the contents of the database are:

mysql> select content from paste where paste_id = '567';
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| content                                                                                                                                                                                                                                                                                                                                                                                                       |
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| # An escaped linefeed
print "\n"

# An escaped escape and an n.
print "\\n"

# An escaped carriage return
print "\r"

# An escaped esacpe and an r.
print "\\r"

# escaped escape
print "\\"

# End of line that's escaped.
print "This string is waaaaaaay too large for me to possibly be able " \
      "to fit it in a single line"

# Some accidental backslashes: \\
# Four backslashes and an n: \\\\n | 
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

The database content suggests the issue is most likely in the mysql library escaping content coming from the database.

Change History

Changed 4 years ago by scott

The output from mysql suggest that mysql.awk is most likely not handling \\ correctly.

scott@megatron:~> echo "select content from paste where paste_id = '567'" | mysql -u<user> -p<password> awkbot 
content
# An escaped linefeed\nprint "\\n"\n\n# An escaped escape and an n.\nprint "\\\\n"\n\n# An escaped carriage return\nprint "\\r"\n\n# An escaped esacpe and an r.\nprint "\\\\r"\n\n# escaped escape\nprint "\\\\"\n\n# End of line that's escaped.\nprint "This string is waaaaaaay too large for me to possibly be able " \\\n      "to fit it in a single line"\n\n# Some accidental backslashes: \\\\\n# Four backslashes and an n: \\\\\\\\n

 the paste actually shows that precedence is being given to \n over \\.

Changed 4 years ago by scott

  • owner changed from gt3 to scott
  • priority changed from major to critical
  • version set to 1.0
  • component changed from IMGV to awkbot
  • milestone set to awkpaste

Changed 4 years ago by scott

  • status changed from new to closed
  • resolution set to fixed

This is fixed in [91] and [92].

Note: See TracTickets for help on using tickets.