Seen this in the test bot a few times, but just got it locally as well.

This is the assertion which fails:

The unmunged (simpletest_lSa.php.txt) filename matches the original (simpletest_lSa_.php.txt)

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Dave Reid’s picture

I have also seen this happen once or twice with the bot. It seems like a very random occurrence.

lilou’s picture

lilou’s picture

Doc (http://api.drupal.org/api/function/file_munge_filename/7) says :

For instance the file name "exploit.php.pps" would become "exploit.php_.pps".

drewish’s picture

subscribing... it would be helpful to know which test specificialy is failing.

webchick’s picture

@drewish: It's the munged vs unmunged comparison. See catch's initial post. Or do you need more info?

drewish’s picture

well the function name so i could pull it up without having to dig through the file... not a biggie but i was hoping to find it on api.drupal.org... but i guess it doesn't do classes...

my guess would be that it's doing a random file name and some percentage of the time the name conflicts with the expectation.

catch’s picture

Status: Active » Reviewed & tested by the community
Issue tags: +Quick fix
FileSize
1.68 KB
664 bytes

This is impossible to reproduce reliably, but I'm seeing about 2-5 patches marked CNW by the test bot a day because of this. Discovered it's slightly quicker to delete the comment then hit retest than post a new comment and hit retest, but it's still annoying as hell and time-consuming to tidy up, and I just realised deleting those comments makes it look like less of a problem than it actually is.

We can change the random name to a fixed one and try that for a while. Or the second patch just comments out that line in the test.

I've switched the test bot off again for now since I keep seeing confused patch posters in the issue queue, hence marking this to RTBC without review so we can at least start it up again.

If we try the first patch for a while to see how it goes that's fine with me, but if not the second should work just fine pending a proper a fix.

catch’s picture

webchick’s picture

Status: Reviewed & tested by the community » Postponed (maintainer needs more info)

I committed the one with the TODO, because I have a distinct feeling that we haven't seen the last of this yet.

Marking active (needs more info) for now. Let's see if this helps. If so, please mark back to fixed, if not, please attach a new patch. :D

webchick’s picture

Also, testing bot now re-enabled.

webchick’s picture

This has been running now for quite a few hours, and seems to be okay so far. The only 'phantom' failure I've seen popping up is #371363: Figure out why "Field form tests" has exceptions sometimes.

sun.core’s picture

Status: Postponed (maintainer needs more info) » Fixed

Proper status.

drewish’s picture

Assigned: Unassigned » drewish
Status: Fixed » Active

ah, i don't think it's actually fixed, just disabled. i'll try to get on this since it should be super simple.

catch’s picture

Priority: Critical » Normal

No longer breaking the test bot, so back to normal for re-adding the test.

c960657’s picture

This restores the original test.

The problem was that randomName() sometimes returned a string ending with underscore, so that $this->name would become e.g. simpletest_lSa_.php.txt. file_unmunge_filename() simply converts "_." to ".", i.e. it strips the underscore that was part of the original filename. Today, randomName() only returns letters and digits, so the test should pass.

I guess we should fix file_unmunge_filename(), though. But as far as I can tell, we cannot do this in a completely bulletproof way. Assume you have two files, foo.bar.txt and foo.bar_.txt. If you munge their filenames and unmunge them again, they will both end up as foo.bar.txt. Admitted, this is probably not a very realistic example, so perhaps less will do.

However, before I begin to fix this issue, I would like to understand the purpose of these functions. It isn't clear to me exactly what security issue they are trying to solve. They were added back in 2006 with the CVS comment fixing stuff. Any ideas?

lilou’s picture

Status: Active » Needs review
c960657’s picture

I raised the question about the purpose of file_munge_filename() in #710640: Improve documentation for file_munge_filename().

ff1’s picture

#15: file-munge-filename-1.patch queued for re-testing.

ff1’s picture

Status: Needs review » Reviewed & tested by the community

file_munge_filename() is now fully documented thanks to #710640: Improve documentation for file_munge_filename().
randomName() problem should be fixed as explained in #15.
Tests pass for patch in #15.

So I can't see any reason not to reinstate this test.

Dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to CVS HEAD. Thanks.

Status: Fixed » Closed (fixed)
Issue tags: -Quick fix

Automatically closed -- issue fixed for 2 weeks with no activity.