Bug 99970 - Strange value of uninitialized input fields
Summary: Strange value of uninitialized input fields
Status: RESOLVED FIXED
Alias: None
Product: konqueror
Classification: Applications
Component: khtml ecma (show other bugs)
Version: unspecified
Platform: RedHat Enterprise Linux Linux
: NOR normal
Target Milestone: ---
Assignee: Konqueror Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-02-22 07:29 UTC by Jan Halasa
Modified: 2005-04-24 20:19 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Test case (550 bytes, text/html)
2005-02-22 07:31 UTC, Jan Halasa
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Halasa 2005-02-22 07:29:30 UTC
Version:            (using KDE KDE 3.3.2)
Installed from:    RedHat RPMs
Compiler:          3.4.2 from Fedora 3
OS:                Linux

Hi,

input elements with no value attribute have a value that causes problems to JavaScript - for example it does not match even simple regexp like ".*". After entering some value or initializing it with value="", it works fine.
I will attach a test case.

Jan
Comment 1 Jan Halasa 2005-02-22 07:31:03 UTC
Created attachment 9769 [details]
Test case

The first text field is a reg exp, the second is a text to match it.
Comment 2 Mario Weilguni 2005-03-04 08:18:50 UTC
Reproduceable with 3.4rc1, works fine in firefox. Since this seems to be javascript related I moved it-
Comment 3 Harri Porten 2005-04-24 19:04:54 UTC
HTMLInputValueImp::value() (html_formimpl.cpp) should never return a null DOMString(). Right now an invalid JS string object is created.
Comment 4 Harri Porten 2005-04-24 20:19:20 UTC
CVS commit by porten: 

value() should never return a null string.

BUGS:99970


  M +6 -4      html_formimpl.cpp   1.421.2.3


--- kdelibs/khtml/html/html_formimpl.cpp  #1.421.2.2:1.421.2.3
@@ -1559,10 +1559,12 @@ DOMString HTMLInputElementImpl::value() 
     }
 
+    DOMString val = m_value;
     // It's important *not* to fall back to the value attribute for file inputs,
     // because that would allow a malicious web page to upload files by setting the
     // value attribute in markup.
-    if (m_value.isNull() && m_type != FILE)
-        return getAttribute(ATTR_VALUE);
-    return m_value;
+    if (val.isNull() && m_type != FILE)
+        val = getAttribute(ATTR_VALUE);
+
+    return val.isNull() ? DOMString("") : val;
 }