Firebase push key - allowed characters - firebase

I am wondering what kind of characters are allowed in the push key. Does it generate also a symbol underscore(_)? I always get a push key with letters with -.

Push keys use a modified Base64 alphabet:
-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz
They are comprised of a timestamp and a random value. The algorithm is described here.
With Firebase keys in general, there is a small set of illegal characters and they are listed in this answer:
Character Set Limitations
Note that URLs used to construct Firebase references may contain any
unicode characters except:
. (period)
$ (dollar sign)
[ (left square bracket)
] (right square bracket)
# (hash or pound sign)
/ (forward slash)

Related

Verify database id in firebase [duplicate]

I am wondering what kind of characters are allowed in the push key. Does it generate also a symbol underscore(_)? I always get a push key with letters with -.
Push keys use a modified Base64 alphabet:
-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz
They are comprised of a timestamp and a random value. The algorithm is described here.
With Firebase keys in general, there is a small set of illegal characters and they are listed in this answer:
Character Set Limitations
Note that URLs used to construct Firebase references may contain any
unicode characters except:
. (period)
$ (dollar sign)
[ (left square bracket)
] (right square bracket)
# (hash or pound sign)
/ (forward slash)

Semicolon in URLs

I have a URL like that: localhost:8080/demo/
And when I call localhost:8080/demo/''''''''' It working fine.
But when I try with localhost:8080/demo/;;; It not working and return HTTP code 404 Not Found.
I tried with few special character # % \ ? / , it returned 400 too.
Anyone can explain it for me?
Thank you so much!
These special characters are not directly allowed in URLs,
because they have special meanings there.
For example:
/ is separator within the path,
? marks the query-part of an URL,
# marks a page-internal link,
etc.
Quoted from Wikipedia: Percent-encoding reserved characters:
When a character from the reserved set (a "reserved character")
has special meaning (a "reserved purpose") in a certain context,
and a URI scheme says that it is necessary to use that character
for some other purpose, then the character must be percent-encoded.
Percent-encoding a reserved character involves converting the
character to its corresponding byte value in ASCII and then
representing that value as a pair of hexadecimal digits. The digits,
preceded by a percent sign (%) which is used as an escape character,
are then used in the URI in place of the reserved character.
For example: ; is a reserved character. Therefore, when ; shall occur
in an URL but without having its special meaning, then it needs to be
replaced by %3B as defined here

HTTP POST request - sending key value pairs - value contains '&'

'&' is used as separator between key and value pairs.
But one of my value contains '&', how can I send this data?
You will have to url encode it (most http related libraries have utility functions for doing so).
For example, key=&value will become key=%26value
You can find more information in Wikipedia.
When a character from the reserved set (a "reserved character") has
special meaning (a "reserved purpose") in a certain context, and a URI
scheme says that it is necessary to use that character for some other
purpose, then the character must be percent-encoded. Percent-encoding
a reserved character involves converting the character to its
corresponding byte value in ASCII and then representing that value as
a pair of hexadecimal digits. The digits, preceded by a percent sign
("%") which is used as an escape character, are then used in the URI
in place of the reserved character. (For a non-ASCII character, it is
typically converted to its byte sequence in UTF-8, and then each byte
value is represented as above.) The reserved character "/", for
example, if used in the "path" component of a URI, has the special
meaning of being a delimiter between path segments. If, according to a
given URI scheme, "/" needs to be in a path segment, then the three
characters "%2F" or "%2f" must be used in the segment instead of a raw
"/".
This question is probably a duplicate of this.

Can't Post data containing $ in a key to Firebase

I'm attempting to post some data into Firebase (relative part of the URL is /messages.json). The following request content:
{"gsx$enddate":"sometime"}
Gives the following error:
Invalid data; couldn't parse JSON object, array, or value. Perhaps you're using invalid characters in your key names.
This is valid JSON however. What am I doing wrong?
It's supposed to be a valid JSON but it seems like it's a limitation for FireBase
From FireBase Documentation:
Character Set Limitations
Note that URLs used to construct Firebase references may contain any
unicode characters except:
. (period)
$ (dollar sign)
[ (left square bracket)
] (right square bracket)
# (hash or pound sign)
/ (forward slash)

How to restrict some file types and allow all others in Regular expression Asp.net

I want to restrict few file types format and allow all others in regular expression validation expression. What i have try is specify some allowed and some restricted file types but i want to specify restricted file types and allow all others type to be uploaded.
I am using regular expression with asp.net file upload control. My regular expression looks like this right now
^.*\.(csv|xlsx|xls|doc|docx|pdf|txt|zip|(?!exe)|(?!bat)|(?!msi))$
Its working fine and restricting exe bat and msi but i want to allow all other file formats
Use a negative lookbehind:
/^.*(?<!\.(exe|bat|msi))$/i
The negative lookaheads you're using aren't helping you. At all. They're trivially true because you're trying to match them at the end of the string, and lookarounds don't consume anything, so the last position in the string can't have exe or bat after it.
A step by step explanation, for posterity's sake:
^
Match the start of the string, as I'm sure you know.
.*
consume the whole string.
(?<! ... )
Look back and make sure we haven't consumed....
\.
A literal dot, followed by...
(exe|bat|msi)
any of our verbotten file types.
$
then match the end of the string.
I also chose to make it case insensitive.
Edit, for js:
/^(?:(?!\.(exe|bat|msi)$).)*/i
Moar different explanation:
^
Top of string
(
Start group
.
Arbitrary Character
(?!...)
Negative lookahead. Not followed by:
\.
Literal dot.
(exe|bat|msi)
Forbidden File types.
$
End of string
)*
Close group and match that an arbitrary number of times.

Resources