Subscribe to
NSLog(); Header Image

MovableType, Search/Replace, and FUCK!

Today I was trying to find an entry today in my blog's "back end." I typed a search term in the top box, hit my keyboard's enter key, and found 0 resuls. So I typed a different search term into the search box provided in the search/replace page. Shortly thereafter the word FUCK came forth from my lips.


For whatever reason, MovableType had begun replacing all instances of "movable" (my second search term) with "" (the empty contents of the "replace" text field). My cursor was clearly in the "Search for:" text box. (See above)

I'm not sure at this point whether this is a Safari bug or a MovableType bug. Thankfully, I archive my database locally, and was able to search my database for the word "movable" and re-edit all the entries affected.

But I wonder how many times this has happened in the past. Just the other day, for example, I searched for "QotD" (to find all Questions of the Day) and they all came up as ": xxxxx" where normally the format is "QotD: xxxxxxx" (xxxx being the title of that question).

Frankly, I'm afraid to test it to find out and a bit too pissed right now to trust myself to think clearly enough to do so properly.

P.S. Safari's history - and the ability to search it - proved invaluable in assuring me that I have not performed any unknown replacements in the past four days.

8 Responses to "MovableType, Search/Replace, and FUCK!"

  1. There should be a check box for replace to work--or at least another button much like in BBedit.

  2. The same thing happened to me a couple of times. Even if it is just a bug in Safari (not about to test it in other browsers though), they should redo the search replace. A check box would be great or even turn it into two completely different pages. It could just warn you before it replaces. Anything at all really.

  3. I don't know whether I'd call it a bug in Safari, but it definitely seems to be a behavior that's different in Safari than most (all?) other browsers.

    It doesn't really matter which form field has focus when you press the enter key. Almost all browsers (except Safari) just submit the form with the first submit button found in that form. In other words, if the submit button has a name, its name and value is passed in the query as a name-value pair. Otherwise, the form is submitted, but no name-value pair is sent for the submit button. In MT, the "Replace" button is named "do_replace", and we check for that query parameter to determine whether or not to do a replace. And in the search/replace form, the "Search" button is the first submit button, so the do_replace="Replace" key-value pair is not sent. So it works fine in most browsers.

    Safari's behavior differs from this--it looks like it submits the form using the first submit button with a name attribute. In the search form, only the replace button has a name, because that's the only one we have to test for ("was the replace button pressed?").

    I think you can fix the problem by explicitly adding a name attribute to the "Search" submit button. But we may just have to rework the form in case other browsers treat this differently.

  4. I think that reworking the form - perhaps as others have suggested to use an explicit "replace" checkbox - is a good way to go, regardless of browser issues. Some sort of confirmation page, perhaps - an "are you sure you want to replace…" page - would also be okay.

    Something needs to be done here. As it currently stands, MovableType is way too cavalier about the destruction of data via find/replace.

    Part of what made the Mac so easy to learn and so accepting of new users is that it stops you and asks for confirmation when you do something potentially destructive. Many apps follow along there. MovableType would do well to follow too.

  5. Uh-Oh. Sounds bad. Thanks for the warning.

    I always use the search field on my public page. Luckily that's quite safe.

  6. How do you search Safari's history?


  7. Bookmarks -> History -> cmd-F

  8. Fuck - this just happened to me. And then I remembered that you posted about it.