You Can Finally Safely Use innerHTML (kind of)

You Can Finally Safely Use innerHTML (kind of)

Web Dev Simplified

1 год назад

283,935 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@kurtj597
@kurtj597 - 16.06.2023 00:17

Next video will be - NEVER USE setHTML

Ответить
@saronarabeds6517
@saronarabeds6517 - 16.06.2023 09:35

What a great programmer man you helped me a lot in my projects, I have a video idea, you can talk about data URI like data:image/svg+xml or data:text/html or data:text/plain

Ответить
@him5518
@him5518 - 16.06.2023 13:25

I feel disappointed because no one mention the 69.420% joke

Ответить
@braindead3370
@braindead3370 - 16.06.2023 15:55

I think that is only useful if you fetch something from the server, not input directly, what is the point of sanitizing input which would you show directly without going through server, it’s the same thing as you messed thing up in developer tool, they can just do whatever they please with it

Ответить
@EmreCanYlmaz0
@EmreCanYlmaz0 - 17.06.2023 10:55

how it is a "mistake" if it's not supported by most browsers

Ответить
@gabydewilde
@gabydewilde - 19.06.2023 02:54

.split('<').join('&lt;')

Ответить
@arbitervildred8999
@arbitervildred8999 - 19.06.2023 20:28

who cares tho... html is a joke

Ответить
@grym6857
@grym6857 - 20.06.2023 16:53

not me forgetting that not everyone uses a framework, wow react really took over my workflow

Ответить
@ali-volcano
@ali-volcano - 21.06.2023 14:16

just a quick question, for javascript how can a user input hack a website? javascript is a client side code... so it doesn't matter ... anyone can use console to write any javascript code they want to run or test on any online page and run the code

Ответить
@ali-volcano
@ali-volcano - 21.06.2023 14:29

this video is total BS and makes me angry, clicking on the "Don't recommend channel button" cya

Ответить
@smorebytes
@smorebytes - 21.06.2023 14:52

Yea we needed this 20 years ago, that would have been real nice. So now we probably have 2 decades worth of applications out there vulnerable from developers that didn't know better back then.

Ответить
@Ammar11635
@Ammar11635 - 21.06.2023 21:03

Can't I just use dev tools in my browser ?

Ответить
@madao2000
@madao2000 - 23.06.2023 10:03

aren't we literally allowed to code in console? which is the same right?

Ответить
@elgs1980
@elgs1980 - 23.06.2023 10:54

You are a hero!

Ответить
@dakoderii4221
@dakoderii4221 - 23.06.2023 18:04

Microsoft having a feature that Firefox doesn't? Edge is much better than IE was.

Ответить
@crackedsam7303
@crackedsam7303 - 27.06.2023 07:04

Idk what this guy is talking about… browser support looks “nice” to me 😊

Ответить
@Vampirat3
@Vampirat3 - 27.06.2023 21:16

Chrome and disgusting edge ,
are corporate browsers that ,
nobody should develop around.

User can download another better private browser.
IDC. deal with it.

I am NEVER developing according to corporate standards.

Ответить
@layer8problem
@layer8problem - 29.06.2023 00:03

So useless and even harmful if someone thinks that this would make the coder safer

Ответить
@theforeskinsnatcher373
@theforeskinsnatcher373 - 29.06.2023 00:17

uh what? I can also go to the console and run javascript from there or modify the html...

Ответить
@stevenleonmusic
@stevenleonmusic - 29.06.2023 17:39

Anyone intelligent enough to inject custom HTML via form input would just use the dev console and inspector to inject whatever they wanted anywhere on the page so this is just silly and unnecessary. There is no such thing as client-side security—it's all just security through ignorance.

Ответить
@grebmann
@grebmann - 30.06.2023 03:03

No one use this 😂

Ответить
@GeriatricMillenial
@GeriatricMillenial - 01.07.2023 06:29

Umm... A malicious actor could accomplish the same from the console. This makes no sense as a tip.

Ответить
@GeriatricMillenial
@GeriatricMillenial - 01.07.2023 06:30

Tell me you went to a boot camp without telling me you went to a boot camp.

Ответить
@abhinavgandham4883
@abhinavgandham4883 - 01.07.2023 13:35

Gonna start using this method from now on.

Ответить
@HuntingKingYT
@HuntingKingYT - 01.07.2023 21:44

but most of all, samy is my hero.

Ответить
@jwstolk
@jwstolk - 01.07.2023 21:56

A super common mistake developers make is that they think there is any security when their website runs on a browser on a computer that they don't own. The owner has access to and can modify every byte in that browser. They can add whatever java-script the want to your website, even without any inputs. Your website may even be running on a simulation of a browser.

Ответить
@Kalukaru
@Kalukaru - 02.07.2023 17:49

Ever opened the inspector in a browser and used the provided console there? xD

Ответить
@dungeonmir
@dungeonmir - 02.07.2023 18:44

Nice😁 but 70% is bad💀

Ответить
@fhudufin
@fhudufin - 03.07.2023 00:23

%69.42 💀💀💀

Ответить
@svaira
@svaira - 03.07.2023 13:36

Or, you know... You could use the escape function.... before you format a random string in.... I don't understand how you can be this stupid tbh. Why would you just use a format string with unescaped data?

Ответить
@Vatz90
@Vatz90 - 04.07.2023 07:00

Cool

Ответить
@marcellomarianetti1770
@marcellomarianetti1770 - 06.07.2023 00:48

browser support being 69.420% noice

Ответить
@jackdavenport5011
@jackdavenport5011 - 07.07.2023 02:35

I can’t believe innerHTML became the standard for setting text in the DOM. Even recent tutorials still use it when it is way less secure than innerText.

Ответить
@davea136
@davea136 - 08.07.2023 05:30

Or, you know, generate the DOM you actually want and insert it.

Ответить
@OursGroumy
@OursGroumy - 08.07.2023 13:44

I don't understand your point, if you want to add JavaScript in the client page, you Can just do it using thé browser console, or even rewrite the HTML of thé page.

Ответить
@DwightTam
@DwightTam - 08.07.2023 20:27

Yeah just did it to my to-do earlier.

Ответить
@DwightTam
@DwightTam - 08.07.2023 20:28

how about eval()

Ответить
@Uselessnoobcow
@Uselessnoobcow - 09.07.2023 11:02

If the client machine wants to break itself with some malicious JS I don’t care, won’t get past my server validation 😂

Ответить
@mibrahim4245
@mibrahim4245 - 11.07.2023 06:52

Great, but this is still in the front end 😢

Ответить
@studiogrym
@studiogrym - 13.07.2023 15:04

there are so many other way to clean your input, why giving people bad advice?

Ответить
@patrick.1943
@patrick.1943 - 14.07.2023 15:51

Super common mistake that developers make is using JavaScript

Ответить
@MohammadTRABELSI
@MohammadTRABELSI - 26.07.2023 21:47

🎉 thanks for this

Ответить
@a4d9
@a4d9 - 28.07.2023 15:22

I have never understood why people do it like this. Create the element instead and insert user supplied text with textContent instead.

Ответить
@radstevee
@radstevee - 31.07.2023 11:20

The percentage is literally 69.420%...

Ответить
@ahmedeveloper
@ahmedeveloper - 07.08.2023 16:50

really thanks

Ответить
@EricRohlfs
@EricRohlfs - 03.09.2023 08:36

Doesn’t like SVG either. Instead I'm using a custom named template literal function that returns a DocumentFragment to append.

Ответить
@Human_Evolution-
@Human_Evolution- - 28.02.2024 23:23

ChatGPT said this video is wrong, in the sense that you can just use sethtml instead of innerhtml. it says it only works in some very specific areas.

Ответить
@dottorcosmic
@dottorcosmic - 09.05.2024 15:53

documentation says that sethtml is still experimental and still not supported

Ответить
@clevermissfox
@clevermissfox - 29.01.2025 03:49

Hm caniuse doesn’t seem to show this anymore. I can only find setHTMLUnsafe which (if I’m reading MDN correctly) DOESNT sanitize. Gah what happened to this method ?!

Ответить