Closed Bug 28950 Opened 25 years ago Closed 24 years ago

wrong type used in nsHeaderEntry which may cause problem when server send bad URL

Categories

(Core :: Networking, defect, P3)

defect

Tracking

()

VERIFIED FIXED

People

(Reporter: ftang, Assigned: gagan)

Details

(Whiteboard: 1d)

I caught this when I tring internet keyword w/ SeaMonkey




 35 class nsHeaderEntry : public nsIHTTPHeader
 36 {
 37 public:
 38   // nsISupports methods:
 39   NS_DECL_ISUPPORTS
 40 
 41   // nsIHTTPHeader methods:
 42   NS_DECL_NSIHTTPHEADER
 43 
 44   nsHeaderEntry(nsIAtom* aHeaderAtom, const char* aValue);
 45   virtual ~nsHeaderEntry();
 46 
 47   nsCOMPtr<nsIAtom> mAtom;
 48   nsString          mValue;
 49 };

suggest change. Change the line 48 nsString mValue to nsCString
The reason is the value you got from the net is char* not unicode and nsString 
use PRUnichar internal but nsCString use char*
nsString have more restrick sematic than nsCString.
In case that server send you non ASCII in the header (they should not, but 
currently our keyword server does) we should not cast it to nsString which may 
cause unwantted conversion.

more info will be included...
=> gagan

[Maybe we should eliminate the nsString(char*) constructor in favor of something 
with a charset converter that makes us "swear this is ascii". It seems all too 
easy to make this mistake.]
Assignee: warren → gagan
Status: NEW → ASSIGNED
Target Milestone: M14
Keywords: beta2
Moving to M15
Target Milestone: M14 → M15
Moving what's not done for M15 to M16.
Target Milestone: M15 → M16
Whiteboard: 1d
fix checked in. 
Status: ASSIGNED → RESOLVED
Closed: 24 years ago
Resolution: --- → FIXED
Keywords: nsbeta2
verified
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.