I got a call today from a user who was having a weird problem when trying to save data on a form. Upon inspection, it turned out that there were a set of double-quotes in the data.
So why is this a problem? As far as ColdFusion cares, it's not, and the data was actually getting saved to the database correctly. The problem appeared when doing an edit. Everything after the first double-quote was being cutoff.
Upon further inspection of the HTML being generated, it seems that is where the problem came in. ColdFusion was doing it's job by outputting the double-quotes, with no knowledge of where in the page that data is being used. And if you use it in a form, you've got problems because it will appear to the user that the data is not saving.
The solution is to use HTMLEditFormat() when outputting values into form fields. This will cause any HTML special characters to change to their entity notations. So the HTML that is generated will actually look something like this:
but it will display on the form as normal double-quotes, and will submit as that too:
This may be common knowledge to many of you, but I'd bet there's a whole bunch of developers who don't even realize this could be an issue. Hopefully this will help prevent some hard-to-track bugs!
| Sun | Mon | Tue | Wed | Thu | Fri | Sat |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | ||
| 6 | 7 | 8 | 9 | 10 | 11 | 12 |
| 13 | 14 | 15 | 16 | 17 | 18 | 19 |
| 20 | 21 | 22 | 23 | 24 | 25 | 26 |
| 27 | 28 | 29 | 30 | 31 |
Project Tracker v2.0 Released
Joe Danziger said: @Doug - thanks, glad you like the app! You can add the following to the <cfapplication> call ...
[More]
Project Tracker v2.0 Released
Doug said: Great App!
How can I increase the time before the session times out? thanks!
[More]
Project Tracker v2.0 Released
Joe Danziger said: @Ron - You can access the demo with username admin and password admin.
[More]
Project Tracker v2.0 Released
Ron Stewart said: Joe: from the screenshots and the blog entries, this looks pretty cool. I'd like to play in the demo...
[More]
Project Tracker v2.0 Released
Mike G said: very very very nice work Dan, nearly blew my load when I saw you even included an API to access ever...
[More]
Yes I'm amazed at the projects that I am on where they don't take that into account when building forms. It's also worth noting, that when you're using the cfinput suite of tags, you don't have to worry about htmleditformat() as it's built into the tag.
Thanks!