Closed Bug 282672 Opened 20 years ago Closed 20 years ago

nsSchemaValidator::IsValidSchemaFloat needs fixed

Categories

(Core Graveyard :: Web Services, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: jwatt, Assigned: jwatt)

References

()

Details

Attachments

(1 file, 1 obsolete file)

As noted by bz, PR_snprintf is locale-sensitive. After converting from a string to a float and back to a string, the resulting string may contain a different decimal separator from the original. Also the comparison should be if(strcmp()!=0) and not if(strcmp()==0).
Attached patch perhaps this? (obsolete) — Splinter Review
Any reason(s) why we can't just do this?
Actually, my new code (being reviewed) does do this :) But its a good idea to fix the existing code.
Comment on attachment 174654 [details] [diff] [review] perhaps this? I'll check it in when I get into work (no need for sr, this is nont-built-by-default code :)
Attachment #174654 - Flags: review+
I can check in my own patches -- unless you have a really strong preference for doing it yourself. ;-) I presume you noticed that this patch will allow leading and trailing whitespace around the value. Also, it seems to me that the way things are currently done should return false for numbers with more decimal digits than can be stored in a float. Where is the code that's being reviewed BTW?
(In reply to comment #4) > I can check in my own patches Although I should point out that it was bz that suggested that ToFloat could be used.
Is there a reason that patch is still converting the string to UTF8?
Hmm, no, good point. But why isn't ToFloat in nsAString?
Because it was only implemented for nsString/nsCString.... But you could use an nsAutoString here.
bug 223097 has the new, nsAutoString using version of the code. Actually, it seems I never got around to changing Float to using what you are, thought I had.
Good point. Here's a new patch.
Attachment #174654 - Attachment is obsolete: true
doron: I notice that you took out the "#ifdef DEBUG" code from your new patch. Do you want that here too?
no need
Marking FIXED. Checking in mozilla/extensions/schema-validation/src/nsSchemaValidator.cpp; /cvsroot/mozilla/extensions/schema-validation/src/nsSchemaValidator.cpp,v <-- nsSchemaValidator.cpp new revision: 1.9; previous revision: 1.8 done
Status: NEW → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: