After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 628893 - Error with string-append and gimp-drawable-get-name, when the layer name contains certain characters.
Error with string-append and gimp-drawable-get-name, when the layer name cont...
Status: RESOLVED FIXED
Product: GIMP
Classification: Other
Component: Script-Fu
2.6.7
Other Linux
: Normal normal
: 2.6
Assigned To: GIMP Bugs
GIMP Bugs
Depends on:
Blocks:
 
 
Reported: 2010-09-06 15:04 UTC by florent53
Modified: 2010-09-21 03:37 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Proposed patch (1.37 KB, patch)
2010-09-20 15:09 UTC, Massimo
none Details | Review

Description florent53 2010-09-06 15:04:52 UTC
-> Open GIMP 2.6 and create a new image.
-> Create two new layers named "é" and "e".
-> Open the script-fu console.
-> Get the ID of each layer.
     (to get the ID of a layer:
	-get the ID (imageID) of the image by seeing the top of its window
         (imageName-imageID)
	-in the layer dialog select the layer that you want to now its ID
	-type this on the console : (gimp-image-get-active-drawable imageID) ,
         it returns the active layer ID
     )

-> type this:
	> (car (gimp-drawable-get-name lay1))
  	==> "é"
	> (car (gimp-drawable-get-name lay2))
	==> "e"
   for the moment : no error	
   (> means what you type, ==> means what GIMP returns, lay1 is the ID of the 
   layer named "é" and lay2 is the ID of the layer named "e")

-> type this:
	> (string-append "é" "a")
	==> "éa"
	> (string-append "e" "a")
	==> "ea"
   no error

-> type this:
	> (string-append (car (gimp-drawable-get-name lay1)) "a")
	==>
	> (string-append (car (gimp-drawable-get-name lay2)) "a")
	==> "ea"
   The second expression does not create an error.
   The first expression must returns "éa" but GIMP does not return anything.

-> type this :
	> (string-append (car (gimp-drawable-get-name lay1)) "é")
	==>
	> (string-append (car (gimp-drawable-get-name lay2)) "é")
	==> "eé"
   Note that the behaviour of GIMP is the same if you type "a" or any other
   character or string in the string-append expression.

-> type this
	> (gimp-drawable-set-name lay1 
            (string-append (car (gimp-drawable-get-name lay1)) "a") )
	==> Error: Procedure execution of gimp-drawable-set-name failed on 
            invalid input arguments: La procédure « gimp-drawable-set-name » a 
            été appelée avec la valeur «  
	> (gimp-drawable-set-name lay2
            (string-append (car (gimp-drawable-get-name lay2)) "a") )
	==> (#t)
   The first expression returns an error, it is logic because the string-append 
   expression does not return anything.

-> Now change the name of the layer named "é" by "²", "è", "à", "°","§", "ù",
   "§", "ù", "ô", "ï" or what you want.
   Note that if the name of the layer contains certain characters and if you 
   type this : (string-append (car (gimp-drawable-get-name lay1)) "a") ,  it 
   generates an error.

Comment 1 Kevin Cozens 2010-09-16 20:47:53 UTC
This bug appears to be a duplicate of #572865 (see the end of comment #2). I'm leaving this report open for now as it has additional test cases.
Comment 2 Kevin Cozens 2010-09-19 15:43:43 UTC
Confirming. I have a fixed one bug in string-append but I'm still seeing some problems with a couple of the other test cases in this report.
Comment 3 Kevin Cozens 2010-09-20 01:02:11 UTC
Fixed in the 2.6 branch of GIMP:
commit 136bfb61cc655d51b0ee7066f5126ceb33cf56c5
    First part of fixes for handling UTF-8 coded strings (Bugs 572865 & 628893)
commit c00dfc97d7bf8f47e4bb888079d6675f3e791e1e
    Last part of fixes for handling UTF-8 coded strings (Bugs 572865 & 628893)

Fixed in the master branch of GIMP.
commit 68552674702653abde0bfc5d4b0cd84d045b5d92
    First part of fixes for handling UTF-8 coded strings (Bugs 572865 & 628893)
commit ae6670ba8b20f03a7d12d5eba57c5be3b9dcb1db
    Last part of fixes for handling UTF-8 coded strings (Bugs 572865 & 628893)
Comment 4 Massimo 2010-09-20 15:09:21 UTC
Created attachment 170671 [details] [review]
Proposed patch

Executing OP_STRAPPEND and OP_SUBSTR you call 'mk_empty_string'
to initialize a cell pointer and to allocate the string. But that
way, if the string contains non-ASCII characters the 'strlength'
is initialized with the number of bytes.

Try:

Welcome to TinyScheme
Copyright (c) Dimitrios Souflis
Script-Fu Console - Interactive Scheme Development

> (define b (make-string 2 (integer->char 931)))
b
> (define a (string-append b b))
a
> (string-length a)
4
> (string-length (string-append a a))
4


Welcome to TinyScheme
Copyright (c) Dimitrios Souflis
Script-Fu Console - Interactive Scheme Development

> (define b (make-string 8 (integer->char 931)))
b
> (define a (substring b 4))
a
> (string-length a)
4
> (string-length (string-append a a))
4
Comment 5 Kevin Cozens 2010-09-21 03:37:51 UTC
Fixed in the 2.6 branch of GIMP:
commit 0a6d646c4af2ac5cb3afbc2ca7b477615ab36469
    Additional fixes for handling UTF-8 coded strings (Bugs 572865 & 628893)

Fixed in the master branch of GIMP.
commit b0d8ba5ffddd46798a7480d75f5de3c8d808b9ad
    Additional fixes for handling UTF-8 coded strings (Bugs 572865 & 628893)