From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Fri, 16 Mar 2001 13:36:05 +0400 (SAMT) From: Vlad Harchev X-Sender: hvv@localhost.localdomain To: sisyphus@linuxteam.iplabs.ru Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=koi8-r Content-Transfer-Encoding: QUOTED-PRINTABLE Subject: [sisyphus] Re: gdk_selection.c:sanitize_ctext is broken in 1.2.9 (fwd) Sender: sisyphus-admin@linuxteam.iplabs.ru Errors-To: sisyphus-admin@linuxteam.iplabs.ru X-BeenThere: sisyphus@linuxteam.iplabs.ru X-Mailman-Version: 2.0 Precedence: bulk Reply-To: sisyphus@linuxteam.iplabs.ru List-Help: List-Post: List-Subscribe: , List-Id: List-Unsubscribe: , List-Archive: Archived-At: List-Archive: List-Post: =E4=CF=C2=D2=D9=CA =C4=C5=CE=D8! =E1=CC=C5=CB=D3=C5=CA, =CB=C1=CB =F7=D9 =CF=C3=C5=CE=C9=D7=C1=C5=D4=C5 =DC= =D4=CF=D4 =D0=C1=D4=DE? =F3=D4=CF=C9=D4 =CC=C9 =EF=D7=C5=CE=D5 =C5=C7=CF = =CB=CF=CD=CD=C9=D4=C9=D4=D8 =C9=CC=C9 =CD=CF=C7=D5=D4 =C2=D9=D4=D8 =CB=C1=CB=C9=C5-=CE=C9=D4=D8 =D0=D2=CF=C2=CC=C5=CD=D9? Best regards, -Vlad ---------- Forwarded message ---------- Date: 15 Mar 2001 14:13:06 -0500 From: Owen Taylor Cc: hvv@hippo.ru To: gtk-devel-list@gnome.org Subject: Re: gdk_selection.c:sanitize_ctext is broken in 1.2.9 User-Agent: Gnus/5.0807 (Gnus v5.8.7) Emacs/20.7 Vlad Harchev writes: > On 13 Mar 2001, Owen Taylor wrote: > > OK, looking again at the Xlib code and the CTEXT spec, it appears that > > the CTEXT spec was at some point extended to accomodate this (section > > 6) but the initial section that describes what characters are allowed > > was never updated :-(. > >=20 > > Unfortunately, according to the spec, anything is allowed in an > > extended segment, including all of C0 and C1, so probably we need to > > add explicit recognition of extended segments to sanitize_ctext(). [...] > Thanks you for this. >=20 > I want to add that I just tried gtk+-1.2.9 and found that I can't cut an= d > paste russian to/from any gtk widget due to brokeness of sanitize_ctext! = That > hackish patch fixes the problem. So the problem should be definitely fixe= d! Patch appended fixes cut-and-paste of Russian for me. =20 > Also small addition: by the "old XFree servers" ANY XFree with version <= =3D > 4.0.1 was ment in my mail. I dont' understand what you meant by this. Are there problems that occcur with old XFree86 libraries (server is irrelevant) that don't occur with current XFree86 libraries? Owen Index: gdkselection.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/gnome/gtk+/gdk/Attic/gdkselection.c,v retrieving revision 1.6.2.6 diff -u -r1.6.2.6 gdkselection.c --- gdkselection.c=092001/02/22 20:38:12=091.6.2.6 +++ gdkselection.c=092001/03/15 19:09:51 @@ -208,16 +208,40 @@ gchar *result =3D g_malloc (*length + 1); gint out_length =3D 0; gint i; + const guchar *ustr =3D (const guchar *)str; =20 for (i=3D0; i < *length; i++) { - guchar c =3D ((guchar *)str)[i]; + guchar c =3D ustr[i]; =20 if (c =3D=3D '\r') =09{ =09 result[out_length++] =3D '\n'; -=09 if (i + 1 < *length && str[i + 1] =3D=3D '\n') +=09 if (i + 1 < *length && ustr[i + 1] =3D=3D '\n') =09 i++; +=09} + else if (c =3D=3D 27 /* ESC */) +=09{ +=09 /* Check for "extended segments, which can contain arbitrary +=09 * octets. See CTEXT spec, section 6. +=09 */ + +=09 if (i + 5 < *length && +=09 ustr[i + 1] =3D=3D '%' && +=09 ustr[i + 2] =3D=3D '/' && +=09 (ustr[i + 3] >=3D 48 && ustr[i + 3] <=3D 52) && +=09 ustr[i + 4] >=3D 128 && +=09 ustr[i + 5] >=3D 128) +=09 { +=09 int extra_len =3D 6 + (ustr[i + 4] - 128) * 128 + ustr[i + 5] - 1= 28; +=09 extra_len =3D MAX (extra_len, *length - i); + +=09 memcpy (result + out_length, ustr + i, extra_len); +=09 out_length +=3D extra_len; +=09 i +=3D extra_len - 1; +=09 } +=09 else +=09 result[out_length++] =3D c;=09 =20 =09} else if (c =3D=3D '\n' || c =3D=3D '\t' || c =3D=3D 27 /* ESC */ || =09 (c >=3D 32 && c <=3D 127) ||=09/* GL */