You should use htmlspecialchars()
or an equivalent text-to-HTML encoding function on $_SERVER['PHP_SELF']
or any other text variables.
The question of trusted/untrusted sources of data is missing a more fundamental point: you should not treat plain text as though it is HTML. If you are going to ever display a text value, you need escape/encode it as HTML, whether it comes from a safe source or not. (This often makes things easier to reason about: most sources of data are plain text, and should always be escaped. You only need to careful consider the safety of the data source for the few cases that you're getting HTML data, so there are fewer chances to make a mistake.)
This variable contains a text value, not an HTML value, so you must encode it!
Is it likely that $_SERVER['PHP_SELF']
will ever contain a value that is actually dangerous? No. It's very unlikely. I've seen some weird cases where it could cause a syntax error in your page, but nothing exploitable (although in a hypothetically contrived situation it could happen). But you should still encode it, because it's the right thing to do, and this habit will protect you in other cases.
If you're just hard-coding the value action="process.php"
into your source code, you're fine. You don't have anything to worry about: you can see that there are no characters that requiring encoding in there. It's as though it's already encoded. And in this case, you don't need to worry about an accidental rename to a future careless filename causing unexpected trouble.