Empty Dumps
yxshv opened this issue · comments
You can create empty Dumps easily,
Having an empty text area and clicking the submit button does not work but you can still create empty Dumps by ctrl
/cmd
enter
But still since this is markdown,
there are many ways to create an empty looking markdown like empty bold texts
** **
simply .trim()
will not be able to recognise these, so you can replace all the *
and _
with
spaces and then trim to find if empty
hey I would like to work on it
so I have been looking on internet to find ways to create empty string in md and found these
(view in raw format to see the result)
[foo]: bar
reference tag result(needs \n between previous line):
so should I handle all this cases? I did wrote some regex for them
/\[s*?\]\(.+?\)/g
/\[\/\/\]:\s*?#\s*?\(.*?\)/g
/\[.*?\]:.+?/g
this handles almost all the edge cases. But we all know regex can easily be exploited so not sure what to do here.
or we can simple do this:
const isValidDump =
dump
.replaceAll(" ", "")
.replaceAll(/\n/g, "")
.replaceAll(/\t/g, "")
.replaceAll("*", "")
.replaceAll("`", "")
.replaceAll("#", "")
.replaceAll("[", "")
.replaceAll("]", "")
.trim().length > 0;
that works for now!
this really needs a better solution but for now we can also replace !
replace it for checks, hmm yeah, what even is the better solution?
any more edge cases?
I can also create empty dumps using []()
this case was mentioned by @piyush-panpaliya , but it wasn't fixed
as in the code here
const isValidDump =
dump
.replaceAll(" ", "")
.replaceAll(/\n/g, "")
.replaceAll(/\t/g, "")
.replaceAll("*", "")
.replaceAll("`", "")
.replaceAll("#", "")
.replaceAll("[", "")
.replaceAll("]", "")
.trim().length > 0;
[]
was replaced, but ()
wasn't