Closed Bug 29154 Opened 25 years ago Closed 25 years ago

nsPresState::SetStateProperty trash non ASCII unicode data

Categories

(Core :: Layout: Form Controls, defect, P3)

defect

Tracking

()

VERIFIED FIXED

People

(Reporter: ftang, Assigned: ftang)

References

Details

(Whiteboard: need feedback from engineer)

I caught this when I try a form upload of non ASCII file name After I hit submit, my tree assert because I turn on my assertion code stated in bug 28424. Assign this to hyatt because cvsblame say he wrote those code. I think nsPresState should use nsISupportWString instead of nsISupportString to hold the data so we won't lost the upper 8 bits of the Unicode Here is the stack trace nsString::ToNewCString() line 669 nsPresState::SetStateProperty(nsPresState * const 0x02eae310, const nsString & {...}, const nsString & {...}) line 91 + 9 bytes nsFileControlFrame::SaveState(nsFileControlFrame * const 0x021b80cc, nsIPresContext * 0x02ed3480, nsIPresState * * 0x0012f398) line 556 + 49 bytes CaptureFrameStateFor(nsIPresContext * 0x02ed3480, nsIFrame * 0x021b8074, nsILayoutHistoryState * 0x02b765f0) line 1402 + 40 bytes FrameManager::CaptureFrameState(FrameManager * const 0x02b53620, nsIPresContext * 0x02ed3480, nsIFrame * 0x021b8074, nsILayoutHistoryState * 0x02b765f0) line 1420 + 17 bytes FrameManager::CaptureFrameState(FrameManager * const 0x02b53620, nsIPresContext * 0x02ed3480, nsIFrame * 0x00f0b2c8, nsILayoutHistoryState * 0x02b765f0) line 1429 + 24 bytes FrameManager::CaptureFrameState(FrameManager * const 0x02b53620, nsIPresContext * 0x02ed3480, nsIFrame * 0x00f9efb4, nsILayoutHistoryState * 0x02b765f0) line 1429 + 24 bytes FrameManager::CaptureFrameState(FrameManager * const 0x02b53620, nsIPresContext * 0x02ed3480, nsIFrame * 0x00f9ef2c, nsILayoutHistoryState * 0x02b765f0) line 1429 + 24 bytes FrameManager::CaptureFrameState(FrameManager * const 0x02b53620, nsIPresContext * 0x02ed3480, nsIFrame * 0x00facedc, nsILayoutHistoryState * 0x02b765f0) line 1429 + 24 bytes FrameManager::CaptureFrameState(FrameManager * const 0x02b53620, nsIPresContext * 0x02ed3480, nsIFrame * 0x00facf64, nsILayoutHistoryState * 0x02b765f0) line 1429 + 24 bytes FrameManager::CaptureFrameState(FrameManager * const 0x02b53620, nsIPresContext * 0x02ed3480, nsIFrame * 0x00facf18, nsILayoutHistoryState * 0x02b765f0) line 1429 + 24 bytes FrameManager::CaptureFrameState(FrameManager * const 0x02b53620, nsIPresContext * 0x02ed3480, nsIFrame * 0x00facea0, nsILayoutHistoryState * 0x02b765f0) line 1429 + 24 bytes PresShell::GetHistoryState(PresShell * const 0x02b53b60, nsILayoutHistoryState * * 0x0012f644) line 2459 + 47 bytes nsWebShell::GetHistoryState(nsWebShell * const 0x02b34e20, nsISupports * * 0x0012f644) line 2529 + 30 bytes nsWebShell::LoadURL(nsWebShell * const 0x02b34e20, const unsigned short * 0x02c20340, const char * 0x003829a4, nsIInputStream * 0x02c204a0, int 0x00000001, unsigned int 0x00000000, const unsigned int 0x00000000, nsISupports * 0x00000000, const unsigned short * 0x02b36ef0, const char * 0x0012fc30) line 2197 + 45 bytes nsWebShell::HandleLinkClickEvent(nsIContent * 0x02be4560, nsLinkVerb eLinkVerb_Replace, const unsigned short * 0x02c20340, const unsigned short * 0x10083548 gCommonEmptyBuffer, nsIInputStream * 0x02c204a0) line 2771 + 95 bytes OnLinkClickEvent::HandleEvent() line 2648
Blocks: 28424
Status: NEW → ASSIGNED
Target Milestone: M17
Depends on: 22580
Blocks: 28019
No longer blocks: 28019
The dependency is wrong- this bug should block 22580 not 22580 blocking it.
No longer depends on: 22580
Blocks: 22580
I think this is a beta1 bug. The bug trash data . We need this to fix 22580. add beta1 keyword
Keywords: beta1
Give me a patch. You can fix this.
Here is the patch. After apply this 22580 is fixed. to test this under Western Window system. User SeaMonkey to visit http://warp/u/ftang/tmp/nonLatin1.html (do not use 4.x to visit, I use &#xXXX; which 4.x do not recognize these kind of NCR) . Copy and past those text into any form, submit and click Back. Without this fix. Most of the text turn into ., with this fix, those characters preserved Index: nsPresState.cpp =================================================================== RCS file: /m/pub/mozilla/layout/base/src/nsPresState.cpp,v retrieving revision 3.2 diff -c -r3.2 nsPresState.cpp *** nsPresState.cpp 2000/02/01 02:14:29 3.2 --- nsPresState.cpp 2000/03/03 09:13:47 *************** *** 59,71 **** nsPresState::GetStateProperty(const nsString& aName, nsString& aResult) { // Retrieve from hashtable. ! nsCOMPtr<nsISupportsString> str; nsStringKey key(aName); if (mPropertyTable) ! str = dont_AddRef(NS_STATIC_CAST(nsISupportsString*, mPropertyTable->Get(&key))); if (str) { ! char* data; str->GetData(&data); aResult = data; nsAllocator::Free(data); --- 59,71 ---- nsPresState::GetStateProperty(const nsString& aName, nsString& aResult) { // Retrieve from hashtable. ! nsCOMPtr<nsISupportsWString> str; nsStringKey key(aName); if (mPropertyTable) ! str = dont_AddRef(NS_STATIC_CAST(nsISupportsWString*, mPropertyTable->Get(&key))); if (str) { ! PRUnichar* data; str->GetData(&data); aResult = data; nsAllocator::Free(data); *************** *** 84,94 **** // Add to hashtable nsStringKey key(aName); ! nsCOMPtr<nsISupportsString> supportsStr; ! nsresult rv = nsComponentManager::CreateInstance(NS_SUPPORTS_STRING_PROGID, nsnull, ! NS_GET_IID(nsISupportsString), getter_AddRefs(supportsStr)); ! char* val = aValue.ToNewCString(); supportsStr->SetData(val); nsAllocator::Free(val); mPropertyTable->Put(&key, supportsStr); --- 84,94 ---- // Add to hashtable nsStringKey key(aName); ! nsCOMPtr<nsISupportsWString> supportsStr; ! nsresult rv = nsComponentManager::CreateInstance(NS_SUPPORTS_WSTRING_PROGID, nsnull, ! NS_GET_IID(nsISupportsWString), getter_AddRefs(supportsStr)); ! PRUnichar* val = aValue.ToNewUnicode(); supportsStr->SetData(val); nsAllocator::Free(val); mPropertyTable->Put(&key, supportsStr); Remove Target M stone. Hyatt- I can fix this bug, but I need your code review and approval. Reassign to ftang M15
Assignee: hyatt → ftang
Status: ASSIGNED → NEW
Whiteboard: fix available.
Target Milestone: M17 → M15
PDT-
Whiteboard: fix available. → [PDT-] fix available.
both pollmann and hyatt reviewed the code.
Status: NEW → ASSIGNED
Whiteboard: [PDT-] fix available. → [PDT-] fix available. reviewed. Wait for a= from rickg
*** Bug 22580 has been marked as a duplicate of this bug. ***
Whiteboard: [PDT-] fix available. reviewed. Wait for a= from rickg → [PDT-] fix available. reviewed. a=rickg, wait till after dinner to check in...
fixed and check in.
Status: ASSIGNED → RESOLVED
Closed: 25 years ago
Resolution: --- → FIXED
ftang, can you supply a testcase? I'm not clear what you mean by doing a form upload of a "non ASCII file name". As soon as I get the TC, I'll verify this for you...thanks. -Chris
Whiteboard: [PDT-] fix available. reviewed. a=rickg, wait till after dinner to check in... → need feedback from engineer
Updating QA contact.
QA Contact: ckritzer → bsharma
Verifying as for developer's coments
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.