Encrypted code converts title case file names to lower case. Is this a bug?

My extension WinDoor+ came back as approved from validation but when I tried out the downloaded encrypted code, none of the menus loaded. I checked the value of a module variable I used to collect the names of the extension files as they loaded and found that the encrypted code converted title case names to lower case only. My unecrypted code does not do this. Is this an encryption bug or should I defensively assumed that case sensitivity is not always a given?

This is the code I use to fill an array with the names of files as they load. It is at the end of each file just before the extension module end .

this_file = __FILE__
@files_loaded << File.basename(this_file, File.extname(this_file))

I added a getter method to the module to see what was in @files_loaded and found that all the file names were in lower case in the downloaded version of the extension but not in my unencrypted version.

Renaming sounds like a bug in the encryption. However, in Ruby files should be named in snake_case (i.e. lowercase).

When I start SketchUp with the downloaded encrypted extension and check my @file_names module array variable all the names in the array are in lower case, but the actual file names are in title case. My unencrypted code doesn’t do this. SketchUp should be told about this issue but I’m not sure how.

Thank you for your advice about the ruby file naming convention which I hadn’t heard about before. I like my title case file names but if it is against convention then I will change them.

I think writing some example code that quickly shows the difference between the expected and current behavior would help to get this logged.

I’m not sure this is within the scope of the SketchUp API issue tracker (as the error technically doesn’t appear to be in the API) but it could be worth a shot. You can also tag some of the team members here.

Edit: Oh, and isolating the problem is always good too. If I understand this correctly the array and instance variable isn’t a part of the actual problem, but what lead you to find it. Without having looked closely at it myself I get the impression the real problem is the encryption renaming files, or maybe FILE being wrong, is that right?

encryption is renaming files who’s names were in title or camel case to file names in lower case only.

Edit: i notice alot of the extensions have upper case in their ruby file names. Their code probably doesn’t refer to the their file names but if ever it did and the code was encrypted there would be problems.

1 Like

So basically making them all lowercase regardless of initial capitalization?

@thomthom, @ChrisFullmer, is this a known issue with the encryption process?

yes that is correct. Encryption makes them all lower case regardless of capitalization. That is it seems to convert the return value of

__FILE__ 

to lower case only.

1 Like

does it break your extension?

SU downcases some paths to avoid cross platform issues…

i.e. we used to have to use [Pp]lugins to account for the difference between the mac and pc Plugins folder name capitalisation…

now both work on both platforms…

john

Yes, it broke my extension. I used a conditional test to check that all three critical .rbe files had loaded before running the menu code. I used the @files_loaded module variable to hold the file names when they loaded. Encryption made them all lower case. That then broke my conditional check. I have now renamed all my .rb files to lower case file names in line with Ruby convention. This gets around the bug without fixing it. I resubmitted my extension so altered this morning. It works fine as unencrypted code on my machine in English, French and German. I look forward to seeing how it works when I get it back from the Extension Warehouse.

To clarify, are file named changed to all lowercase when encrypting or does __FILE__ return lowercase string regardless of actual file name capitalization?

__FILE__

returns lowercase even though the files have title and camel case names. But only in the encrypted version of the extension.

1 Like

Can you log this in our issue tracker?

Done. Hope I did it right.

2 Likes