Welcome to DU! The truly grassroots left-of-center political community where regular people, not algorithms, drive the discussions and set the standards. Join the community: Create a free account Support DU (and get rid of ads!): Become a Star Member Latest Breaking News General Discussion The DU Lounge All Forums Issue Forums Culture Forums Alliance Forums Region Forums Support Forums Help & Search

highplainsdem

(49,004 posts)
Sat Oct 28, 2023, 01:57 PM Oct 2023

Something very strange is going on with backslashes in DU mail and board messages

I noticed this first with DU mail.

When you have a contraction - any contraction - in the title of mail you're about to send, and you preview it, the preview will show a backslash inserted in front to the apostrophe.

That backslash will disappear when the mail is sent.

I started posting a message for this forum about this, and discovered that if a backslash is in the text of a message - I typed haven't with a backslash in front of the apostrophe to show what I meant - that backslash will disappear when it's previewed (from the text that was typed as well as the preview) and will not show up when it's posted.

I tried posting 4 backslashes together. Previewed it, and 2 disappeared. Previewed it again, and another one of the backslashes disappeared. And they also disappeared not just from the preview, but from the text I'd just typed. So I tried posting to the board without previewing (that OP has been self-deleted) and half the backslashes had vanished in what appeared on the board.

Btw, previewing a board post with a contraction in the title does not make a backslash appear before the apostrophe. That happens only with Mail previews.

2 replies = new reply since forum marked as read
Highlight: NoneDon't highlight anything 5 newestHighlight 5 most recent replies
Something very strange is going on with backslashes in DU mail and board messages (Original Post) highplainsdem Oct 2023 OP
Only certain characters are allowed in input fields EarlG Oct 2023 #1
Yes, it does make sense. Thanks for explaining! highplainsdem Oct 2023 #2

EarlG

(21,949 posts)
1. Only certain characters are allowed in input fields
Sat Oct 28, 2023, 02:21 PM
Oct 2023

for security purposes. If we didn't do that, certain characters could be used to insert code strings into input fields which could allow someone to hack the site.

In this case you're using backslashes as an example, which have an additional use. This is a pretty rough explanation, but basically backslashes are used in coding to "escape" characters that come after them, so they're read as text, not code. For example, if you wanted to write something like this:

echo "A double quote mark looks like this " which I think is pretty cool."

... the code would break because when it reached the second double quote it would treat it as the end of the string rather than a text character. In order to avoid a problem like that, you'd use a backslash in front of the double quote to indicate that that it's a text character and not part of the code, like so:

echo "A double quote mark looks like this \" which I think is pretty cool."

Which would generate this:

A double quote mark looks like this " which I think is pretty cool.

The reason you were seeing four, then two, then one backslashes is because when you use four:

\\\\

...backslashes 2 and 4 are being "escaped" by backslashes 1 and 3. Backslashes 1 and 3 will be recognized as code and stripped from the subject line as disallowed characters. However, backslashes 2 and 4 will be recognized as text. That leaves you with:

\\

When you hit preview again, the same thing happens -- backslash 1 "escapes" backslash 2, backslash 1 is stripped from the code, and backslash 2 is allowed as text, which leaves you with:

\

(And by the way, the only reason these backslashes are showing up in my post is because I'm using the HTML code for them and not previewing, otherwise most of them would be stripped out.)

Hope that all makes sense.

Latest Discussions»Help & Search»DU Community Help»Something very strange is...