# Mbox.rb replacing underscores with spaces

**URL:** https://meta.discourse.org/t/mbox-rb-replacing-underscores-with-spaces/49084
**Category:** Development
**Created:** [August 23, 2016, 6:28pm UTC](https://meta.discourse.org/t/mbox-rb-replacing-underscores-with-spaces/49084 "2016-08-23T18:28:56Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [August 23, 2016, 6:28pm UTC](https://meta.discourse.org/t/mbox-rb-replacing-underscores-with-spaces/49084/1 "2016-08-23T18:28:56Z")

</div>

Something in one of these files is replacing underscores with spaces in email addresses. I’m 99% sure that the one I forked did too, but I’m including my copy in case I did something boneheaded.

> <https://github.com/pfaffman/discourse/blob/master/script/import_scripts/mbox.rb>

> <https://github.com/pfaffman/discourse/blob/master/script/import_scripts/base.rb>

is replacing \_ with a space in email addresses.

I can’t find it, and it’s making me crazy. I don’t see that any of the `.gsub`s could be doing it.

Any ideas where I should look, @eviltrout?

---

<div class="post-metadata">

### Author: ![eviltrout](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eviltrout/32/5275_2.png) [@eviltrout](https://meta.discourse.org/u/eviltrout)
#### Post date: [August 23, 2016, 7:36pm UTC](https://meta.discourse.org/t/mbox-rb-replacing-underscores-with-spaces/49084/2 "2016-08-23T19:36:54Z")

</div>

Are you talking about underscores to spaces or spaces to underscores? The title of the topic is different than the body 🙂

I am pretty sure our system does not allow spaces in emails and will replace them, so I wouldn’t be surprised if it uses underscores.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [August 23, 2016, 7:49pm UTC](https://meta.discourse.org/t/mbox-rb-replacing-underscores-with-spaces/49084/3 "2016-08-23T19:49:19Z")

</div>

Fixed the title.

> [@eviltrout](#):
>
> I am pretty sure our system does not allow spaces in emails and will replace them, so I wouldn’t be surprised if it uses underscores.

Right. That’s what’s bizarre. Emails that have underscores in them are ending up causing errors because the underscores are getting replaced with spaces.

`m_smith@gmail.com` becomes `m smith@gmail.com`.

Edit: but it only happens sometimes.

Anyway, I was hoping it was something silly and obvious that I was somehow overlooking. Thanks.

---

<div class="post-metadata">

### Author: ![eviltrout](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eviltrout/32/5275_2.png) [@eviltrout](https://meta.discourse.org/u/eviltrout)
#### Post date: [August 23, 2016, 8:13pm UTC](https://meta.discourse.org/t/mbox-rb-replacing-underscores-with-spaces/49084/4 "2016-08-23T20:13:49Z")

</div>

I personally haven’t seen this, but it might depend on the mbox format. If you could provide an example of an email that is messed up and the original input I can take a look and try to figure it out.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [August 23, 2016, 8:16pm UTC](https://meta.discourse.org/t/mbox-rb-replacing-underscores-with-spaces/49084/5 "2016-08-23T20:16:06Z")

</div>

Thanks, @eviltrout. I’ve added some more debugging messages and will see what I can see.
