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 Editorials & Other Articles General Discussion The DU Lounge All Forums Issue Forums Culture Forums Alliance Forums Region Forums Support Forums Help & Search

EarlG

(22,691 posts)
1. Only certain characters are allowed in input fields
Sat Oct 28, 2023, 01: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.

Recommendations

0 members have recommended this reply (displayed in chronological order):

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