<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>17432</bug_id>
          
          <creation_ts>2008-02-18 18:51:10 -0800</creation_ts>
          <short_desc>String(const char*) constructor is harmful</short_desc>
          <delta_ts>2010-10-21 17:09:30 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>New Bugs</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>INVALID</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>Gtk</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          <dependson>20313</dependson>
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Alp Toker">alp</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>ap</cc>
    
    <cc>darin</cc>
    
    <cc>jmalonzo</cc>
    
    <cc>mrobinson</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>71105</commentid>
    <comment_count>0</comment_count>
    <who name="Alp Toker">alp</who>
    <bug_when>2008-02-18 18:51:10 -0800</bug_when>
    <thetext>String::String(const char*) and the related implicit conversions and operators from const char* are the biggest single source of programming errors in the GTK+ port.

The problem: developers often pass (UTF-8 encoded) const gchar* directly into WebCore functions that accept a String. It&apos;s difficult to catch these bugs at review time unless the patch comes with sufficient context to see what&apos;s going on, which is often not the case. Once landed, the issue won&apos;t be apparent until users try to enter non-ASCII text, so the failure mode is obscure.

eg.

&gt;+    Credential credential = Credential(challengePrivate-&gt;user,
&gt;+                                       challengePrivate-&gt;password,
...

The code looks correct and will work fine since UTF-8 is often valid ASCII until someone tries using a non-ASCII username or password.

I try to catch and correct code to use String::fromUTF8() but this gets missed very often.

We should probably disable the implicit conversions to make people use String::fromUTF8(), at least in any WebCore and WebKit files that use GLib.

Thoughts?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>77456</commentid>
    <comment_count>1</comment_count>
    <who name="Jan Alonzo">jmalonzo</who>
    <bug_when>2008-04-13 21:15:18 -0700</bug_when>
    <thetext>Does this we mean we have to check the string if it&apos;s a valid utf8 before using String::fromUTF8? How do we disable the implicit convertions?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>297733</commentid>
    <comment_count>2</comment_count>
    <who name="Martin Robinson">mrobinson</who>
    <bug_when>2010-10-21 17:09:30 -0700</bug_when>
    <thetext>Agreed, but we should open a bug for these issues as we find them. Closing for now.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>