nsPresState::SetStateProperty trash non ASCII unicode data

VERIFIED FIXED in M15

Status

()

P3
normal
VERIFIED FIXED
19 years ago
18 years ago

People

(Reporter: ftang, Assigned: ftang)

Tracking

Trunk
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: need feedback from engineer)

(Assignee)

Description

19 years ago
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
(Assignee)

Updated

19 years ago
Blocks: 28424

Updated

19 years ago
Status: NEW → ASSIGNED
Target Milestone: M17
(Assignee)

Updated

19 years ago
Depends on: 22580
(Assignee)

Updated

19 years ago
Blocks: 28019
(Assignee)

Updated

19 years ago
No longer blocks: 28019
(Assignee)

Comment 1

19 years ago
The dependency is wrong- this bug should block 22580 not 22580 blocking it.
No longer depends on: 22580
(Assignee)

Updated

19 years ago
Blocks: 22580
(Assignee)

Comment 2

19 years ago
I think this is a beta1 bug. The bug trash data . We need this to fix 22580. add  
beta1 keyword
Keywords: beta1

Comment 3

19 years ago
Give me a patch.  You can fix this.
(Assignee)

Comment 4

19 years ago
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

Comment 5

19 years ago
PDT-
Whiteboard: fix available. → [PDT-] fix available.
(Assignee)

Comment 6

19 years ago
both pollmann and hyatt reviewed the code.
Status: NEW → ASSIGNED
Whiteboard: [PDT-] fix available. → [PDT-] fix available. reviewed. Wait for a= from rickg
(Assignee)

Comment 7

19 years ago
*** Bug 22580 has been marked as a duplicate of this bug. ***
(Assignee)

Updated

19 years ago
Whiteboard: [PDT-] fix available. reviewed. Wait for a= from rickg → [PDT-] fix available. reviewed. a=rickg, wait till after dinner to check in...
(Assignee)

Comment 8

19 years ago
fixed and check in.
Status: ASSIGNED → RESOLVED
Last Resolved: 19 years ago
Resolution: --- → FIXED

Comment 9

19 years ago
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

Comment 10

18 years ago
Updating QA contact.
QA Contact: ckritzer → bsharma

Comment 11

18 years ago
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.