It's good practice to run toLowerCase a hundred times in a row instead of just saying
var url = window.location.href.toLowerCase()
...right? And at least JavaScript if statements are short circuiting, so they're ordered from most likely to least likely ...right?
Well I guess let's just hope that if anyone needs "and" or "or" or a quotation mark in their form they know how to get past the JavaScript, which wouldn't be too hard.
[Thanks to OP for providing a link to the source in this comment. I have also placed it here for ease of access. NOTE: as this is a transcription, it contains only the code visible in the screenshot. The full extent of the code is visible at OP's link.]
Thanks, but I didn't type any of this. I linked to OP's comment in the note at the beginning; they provided a link to the source. I just put the transcription here because it's more useful to have it actually on the post than force people to click through a link (and this way it can contribute to search engine indexing).
Apart from all the things wrong with this, isn't there some better, or atleast cleaner way of checking if a String contains a String? Something along the lines of String.contains(String)
Perhaps it's just the first line of defense? I really hope there is SQL injection protection in the backend.
But that's the thing. If there's real SQL injection / XSS protection on the backend, then this code is superfluous. If there isn't, then this code is dangerous since it means that it was used to tick the "we've protected our app from SQL injection/XSS" requirement box when it really doesn't.
14
u/0011110000110011 Jul 16 '21 edited Jul 16 '21
Check it out here, found on Oracle's terrible unsubscribe page.
It's good practice to run toLowerCase a hundred times in a row instead of just saying
...right? And at least JavaScript if statements are short circuiting, so they're ordered from most likely to least likely ...right?
Well I guess let's just hope that if anyone needs "and" or "or" or a quotation mark in their form they know how to get past the JavaScript, which wouldn't be too hard.
8
u/daterkerjabs Jul 17 '21
Power move putting a UID in your file names
28
u/WallstreetChump Jul 17 '21
That’s not even for sql injection, it looks like it’s filtering for xss
15
u/MurdoMaclachlan public boolean isInt(int i) { return true; } Jul 17 '21
Image Transcription: Code
[Thanks to OP for providing a link to the source in this comment. I have also placed it here for ease of access. NOTE: as this is a transcription, it contains only the code visible in the screenshot. The full extent of the code is visible at OP's link.]
I'm a human volunteer content transcriber for Reddit and you could be too! If you'd like more information on what we do and why we do it, click here!
10
u/RyanNerd shameless Jul 16 '21
Please tell me this isn't actual code in wild. I guess Oracle had to give the Junior's Junior something to do.
5
u/CryoniC-ZA Jul 17 '21
I'm way too lazy to write shit like this.
4
u/[deleted] Jul 17 '21 edited Jul 17 '21
Apart from all the things wrong with this, isn't there some better, or atleast cleaner way of checking if a String contains a String? Something along the lines of String.contains(String)
Edit: there is indeed: String.includes(str)
4
u/queen-adreena Jul 18 '21
How do you get to the third .toLowerCase() without thinking... "Maybe I should just create a variable which holds the url in lower case?"
3
u/Calcaware Jul 18 '21
Thank you.
I turned down a job for Oracle a few years back and I had some regrets.
I feel liberated.
1
u/NoiseGreat8898 Jul 17 '21
Well, it works