Re: A critique of cgi.escape



Jon Ribbens wrote:

Making cgi.escape always escape the '"' character would not break
anything, and would probably fix a few bugs in existing code. Yes,
those bugs are not cgi.escape's fault, but that's no reason not to
be helpful. It's a minor improvement with no downside.

the "improvement with no downside" would bloat down the output for everyone who's using the function in the intended way, and will also break unit tests.

> One thing that is flat-out wrong, by the way, is that cgi.escape()
> does not encode the apostrophe (') character.

it's intentional, of course: you're supposed to use " if you're using cgi.escape(s, True) to escape attributes. again, punishing people who actually read the docs and understand them is not a very good way to maintain software.

btw, you're both missing that cgi.escape isn't good enough for general use anyway, since it doesn't deal with encodings at all. if you want a general purpose function that can be used for everything that can be put in an HTML file, you need more than just a modified cgi.escape. feel free to propose a general-purpose replacement (which should have a new name), but make sure you think through *all* the issues before you do that.

</F>

.



Relevant Pages

  • Re: Did Anyone Backup the "Code Worth Recommending Project"?
    ... The first lesson is that a general-purpose script is a ... The |create| method seems to have some mistakes in part of it. ... If the design is not changed as requirements change, it can get so bad that it seems more attractive to start over with a new codebase. ... The time saved is not just in easing a requirements change; it's the QA, bugs, regression bugs, and bug scrub meetings. ...
    (comp.lang.javascript)
  • Re: Forth as an operating system
    ... programming) a public, general-purpose OS. ... Most bugs during development are innocent blunders, ... exist nor that general purpose operating systems should not ... Is preemption desirable there (perhaps ...
    (comp.lang.forth)