Closed Bug 456502 Opened 17 years ago Closed 15 years ago

nsFind::Find() calls StripChars() on a non-ASCII char

Categories

(Core Graveyard :: Embedding: APIs, defect)

defect
Not set
trivial

Tracking

(Not tracked)

RESOLVED FIXED
mozilla2.0b1

People

(Reporter: sgautherie, Assigned: wesongathedeveloper)

References

()

Details

(Whiteboard: [good first bug])

Attachments

(1 file)

Bug 450048 comment 4 { From Boris Zbarsky (todo: 200+ items) 2008-08-20 14:40:11 PDT The code that calls StripChars on a non-ASCII char is wrong } I'm not sure what the issue is with non-ASCII chars, nor how to fix it. *** http://mxr.mozilla.org/mozilla-central/source/xpcom/glue/nsStringAPI.h#175 http://mxr.mozilla.org/mozilla-central/source/xpcom/glue/nsStringAPI.cpp#142 There might (not) be a few other cases !? http://mxr.mozilla.org/mozilla-central/search?string=StripChars&case=on
The call will remove the wrong char. Instead of removing the char that you want, it'll remove that modulo 255. The right way to fix it is to use an equivalent PRUnichar api, or to hand-write the StripChars code using PRUnichars.
Whiteboard: [good first bug]
(In reply to comment #1) > it'll remove that modulo 255. The point I don't get is ASCII 7 bit vs char 8 bit: |#define CH_SHY ((PRUnichar) 0xAD)|, especially as a |char|, is < 255, isn't it ? > The right way to fix it is to use an equivalent PRUnichar api Is there one ? Should one be added to the String API ?
Ah, if CH_SHY is < 255, then this code is probably OK, though then it needs a big comment (and better yet a PR_STATIC_ASSERT) about that.
Severity: normal → trivial
Attached patch PatchSplinter Review
Seems to me the <= operator is more appropriate.
Assignee: nobody → wesongathedeveloper
Status: NEW → ASSIGNED
Attachment #453871 - Flags: review?(benjamin)
Attachment #453871 - Flags: review?(benjamin) → review+
Keywords: checkin-needed
Status: ASSIGNED → RESOLVED
Closed: 15 years ago
Keywords: checkin-needed
Resolution: --- → FIXED
Target Milestone: --- → mozilla1.9.3a6
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: