Click here to Skip to main content
15,893,161 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: WSO FSOW Pin
Tim Carmichael9-Sep-15 2:01
Tim Carmichael9-Sep-15 2:01 
GeneralRe: WSO FSOW Pin
super9-Sep-15 2:13
professionalsuper9-Sep-15 2:13 
GeneralRe: WSO FSOW Pin
jsc429-Sep-15 2:34
professionaljsc429-Sep-15 2:34 
GeneralRe: WSO FSOW Pin
Tim Carmichael9-Sep-15 2:38
Tim Carmichael9-Sep-15 2:38 
GeneralRe: WSO FSOW Pin
Tim Carmichael9-Sep-15 2:36
Tim Carmichael9-Sep-15 2:36 
GeneralRe: WSO FSOW Pin
RTek239-Sep-15 6:21
professionalRTek239-Sep-15 6:21 
GeneralRe: WSO FSOW Pin
Tim Carmichael9-Sep-15 7:12
Tim Carmichael9-Sep-15 7:12 
QuestionSort of programming question-ish... Pin
Sander Rossel9-Sep-15 0:19
professionalSander Rossel9-Sep-15 0:19 
So not an actual programming question, but very much related to programming.
Maybe more of a rant something.

I'm working on a web project and I need to send some HTML back to the server, let's say "<p>HTML & ENCODING</p>"
So if I do that I get an error, potentially dangerous request... Fine.
How to fix this? I can disable the check, which isn't very safe.
I can escape the string so I get "& lt;p& gt;HTML & amp; ECODING& lt;/p& gt;", but there's no standard function for that.
I found the JavaScript escape function, but that's deprecated.
I found encodeURI or something, but that's, as the name implies, not for HTML.
So we web developers are left with a string replace...
But what to replace? Some people say replace < and >, others say you really need to replace & too and then there's people who say ' and " need replacement.
And then there are (non-standard) libraries that replace just about everything (!, @, #, $, Hebrew, Chinese... etc.).

Why is there no standard function for this?
It's ridiculous as it's indeed as simple as a string replace, but not so simple to know exactly what to replace...
Am I missing something or is ECMA/ISO/Eich (whatever) missing something? Confused | :confused:

For now I'll just replace <, >, &, ' and ", but I won't enjoy doing it...
Visit my blog at Sander's bits - Writing the code you need.
Or read my articles at my CodeProject profile.
Simplicity is prerequisite for reliability.
— Edsger W. Dijkstra
Regards,
Sander

AnswerRe: Sort of programming question-ish... Pin
Nicholas Marty9-Sep-15 0:42
professionalNicholas Marty9-Sep-15 0:42 
GeneralRe: Sort of programming question-ish... Pin
Sander Rossel9-Sep-15 1:27
professionalSander Rossel9-Sep-15 1:27 
AnswerRe: Sort of programming question-ish... Pin
Kornfeld Eliyahu Peter9-Sep-15 0:45
professionalKornfeld Eliyahu Peter9-Sep-15 0:45 
GeneralRe: Sort of programming question-ish... Pin
Sander Rossel9-Sep-15 1:21
professionalSander Rossel9-Sep-15 1:21 
AnswerRe: Sort of programming question-ish... Pin
Jörgen Andersson9-Sep-15 1:00
professionalJörgen Andersson9-Sep-15 1:00 
GeneralRe: Sort of programming question-ish... Pin
Sander Rossel9-Sep-15 1:25
professionalSander Rossel9-Sep-15 1:25 
GeneralRe: Sort of programming question-ish... Pin
Jörgen Andersson9-Sep-15 1:35
professionalJörgen Andersson9-Sep-15 1:35 
Answerprogramming question Pin
_Maxxx_9-Sep-15 1:08
professional_Maxxx_9-Sep-15 1:08 
GeneralRe: programming question Pin
Sander Rossel9-Sep-15 1:19
professionalSander Rossel9-Sep-15 1:19 
JokeRe: programming question Pin
Kornfeld Eliyahu Peter9-Sep-15 1:21
professionalKornfeld Eliyahu Peter9-Sep-15 1:21 
GeneralRe: programming question Pin
Sander Rossel9-Sep-15 1:28
professionalSander Rossel9-Sep-15 1:28 
GeneralRe: programming question Pin
Brittle16189-Sep-15 1:49
Brittle16189-Sep-15 1:49 
GeneralRe: programming question Pin
Kornfeld Eliyahu Peter9-Sep-15 1:51
professionalKornfeld Eliyahu Peter9-Sep-15 1:51 
GeneralRe: programming question Pin
Brittle16189-Sep-15 2:01
Brittle16189-Sep-15 2:01 
AnswerRe: Sort of programming question-ish... Pin
newton.saber9-Sep-15 1:51
newton.saber9-Sep-15 1:51 
GeneralRe: Sort of programming question-ish... Pin
Sander Rossel9-Sep-15 2:59
professionalSander Rossel9-Sep-15 2:59 
GeneralRe: Sort of programming question-ish... Pin
GenJerDan9-Sep-15 6:19
GenJerDan9-Sep-15 6:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.