Don't worry about print "foo"; vs. "foo";. They're supposed to do the same thing; which you use is a matter of personal preference.
To quote mart, from many years ago "print safe is used to force an untrusted print from a trusted layer. This is no different to print in an untrusted layer (which is essentially anything non-system), but in core and the system layers, where everything is trusted by default, it is used to force a little bit through the HTML cleaner." User layers are untrusted, so all prints are "safe" (e.g., no JavaScript).
Leaving out the print keyword is just a shorthand. If the compiler encounters a statement that starts with a string literal (and maybe a few other cases too; I'm not sure) it just assumes you wanted to do a print.
It's up to you whether you want to use it. Most of the time you probably want println anyway, since otherwise you end up with unreadable, obnoxious HTML output that's all on one line and a real pain to debug.
Okie dokie, thanks. I obsessed with readable HTML, so I end up using a ton of \n's. I should probably try to use println more often, rather than trying to shove everything between functions into one print command... *guilty look*
Comments 4
Don't worry about print "foo"; vs. "foo";. They're supposed to do the same thing; which you use is a matter of personal preference.
To quote mart, from many years ago "print safe is used to force an untrusted print from a trusted layer. This is no different to print in an untrusted layer (which is essentially anything non-system), but in core and the system layers, where everything is trusted by default, it is used to force a little bit through the HTML cleaner." User layers are untrusted, so all prints are "safe" (e.g., no JavaScript).
Reply
Reply
Leaving out the print keyword is just a shorthand. If the compiler encounters a statement that starts with a string literal (and maybe a few other cases too; I'm not sure) it just assumes you wanted to do a print.
It's up to you whether you want to use it. Most of the time you probably want println anyway, since otherwise you end up with unreadable, obnoxious HTML output that's all on one line and a real pain to debug.
Reply
Reply
Leave a comment