# vBulletin 5 导入错误（网站字段中的无效字符）以及关于附件的一个快速问题

**URL:** <https://meta.discourse.org/t/vbulletin-5-import-error-invalid-character-in-website-field-and-a-quick-question-about-attachments/161108>\
**Category:** Migration\
**Tags:** vbulletin5\
**Created:** [2020年八月17日 08:23 UTC](https://meta.discourse.org/t/vbulletin-5-import-error-invalid-character-in-website-field-and-a-quick-question-about-attachments/161108 "2020-08-17T08:23:15Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)\
**Post date:** [2020年八月17日 08:23 UTC](https://meta.discourse.org/t/vbulletin-5-import-error-invalid-character-in-website-field-and-a-quick-question-about-attachments/161108/1 "2020-08-17T08:23:15Z")

</div>

大家好！

在三年前成功从 phpBB 导入我的第一个旧论坛后，我很高兴能激励一位国际社区论坛管理员将另一个更大的论坛（18 万成员，160 万条消息）迁移到 Discourse。🎉

该论坛使用的是 vBulletin5。

导入过程一直顺利，直到处理到第 71712 号用户，原因是网站字段中包含无效字符：

`:website=>"http://url-redacted.com - æåñòêîå ïîðíî ñìîòðåòü îíëàéí",`

随后出现了两条错误信息：

`1: from /usr/local/rvm/rubies/ruby-2.6.5/lib/ruby/2.6.0/uri/rfc3986_parser.rb:73:in `parse' /usr/local/rvm/rubies/ruby-2.6.5/lib/ruby/2.6.0/uri/rfc3986_parser.rb:21:in `split': URI must be ascii only "http://url-redacted.com - \u00E6\u00E5\u00F1\u00F2\u00EA\u00EE\u00E5 \u00EF\u00EE\u00F0\u00ED\u00EE \u00F1\u00EC\u00EE\u00F2\u00F0\u00E5\u00F2\u00FC \u00EE\u00ED\u00EB\u00E0\u00E9\u00ED" (URI::InvalidURIError)`

以及：

`1: from /usr/local/rvm/gems/ruby-2.6.5/gems/addressable-2.7.0/lib/addressable/uri.rb:2394:in `defer_validation' /usr/local/rvm/gems/ruby-2.6.5/gems/addressable-2.7.0/lib/addressable/uri.rb:2475:in `validate': Invalid character in host: 'url-redacted.com.com - æåñòêîå ïîðíî ñìîòðåòü îíëàéí' (Addressable::URI::InvalidURIError)`

既然 URL“必须仅为 ASCII 字符”，是否可以考虑直接移除或清理该字段的内容，而不是抛出错误并停止脚本？🤔  
我打算在再次尝试导入之前，先从数据库中删除该用户。

另外，我还有一个问题。头像存储在数据库中，并且已成功导入。

**那么附件呢？** 在我的情况下，它们也默认存储在数据库中（这是 vBulletin 的默认设置）。它们会被自动导入吗？还是需要将它们存储为单独的字段？

---

<div class="post-metadata">

**Author:** ![neounix](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/neounix/32/215617_2.png) [@neounix](https://meta.discourse.org/u/neounix)\
**Post date:** [2020年八月17日 08:36 UTC](https://meta.discourse.org/t/vbulletin-5-import-error-invalid-character-in-website-field-and-a-quick-question-about-attachments/161108/2 "2020-08-17T08:36:53Z")

</div>

嘿 @Canapin

当我们迁移旧的 vB3 论坛时，迁移脚本中出现了很多错误，原因是存在一些奇怪的乱码或奇怪的附件，这些内容在 15 年的发帖过程中污染了数据库。

我采取的方法虽然不太优雅，但对我们有效：

当遇到这些错误时，我直接编辑了出错位置的迁移脚本，将出错的代码行用以下方式包裹起来：

```plaintext
begin
# 出错的 Ruby 代码行
rescue
puts "这里有一些有趣的出错信息"
end

```

根据我将大约 100 万篇 vB3 帖子迁移到 Discourse 的经验，我最信赖的“朋友”之一就是：

```plaintext
begin
rescue
end

```

我们确实丢失了一些格式错误的帖子，但对我来说，从一百万篇帖子中丢弃少量帖子是可以接受的。

希望这能帮到你。

---

<div class="post-metadata">

**Author:** ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)\
**Post date:** [2020年八月17日 09:04 UTC](https://meta.discourse.org/t/vbulletin-5-import-error-invalid-character-in-website-field-and-a-quick-question-about-attachments/161108/3 "2020-08-17T09:04:44Z")

</div>

由于我不熟悉 Rails，我只是将网站字段的内容替换为空字符串。反正那也是个垃圾账号，而且在已处理的近一半用户中，这是唯一的错误。

因此，如果脚本代码中最终没有修复这个问题，也不算什么大事，不过如果它不阻塞导入过程就更好了：😉

至于附件，无论如何我都会尝试导入消息，并看看附件是否被导入（或者是否会出现任何错误信息），如果在此期间我得不到相关信息的。

---

<div class="post-metadata">

**Author:** ![neounix](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/neounix/32/215617_2.png) [@neounix](https://meta.discourse.org/u/neounix)\
**Post date:** [2020年八月17日 09:15 UTC](https://meta.discourse.org/t/vbulletin-5-import-error-invalid-character-in-website-field-and-a-quick-question-about-attachments/161108/4 "2020-08-17T09:15:29Z")

</div>

> [@Canapin](#):
>
> 至于附件，无论如何我都会尝试导入这些消息，如果在此期间没有获得这些信息，我会看看附件是否被导入（或者是否有任何错误消息）。

你好 @Canapin

在我们把 vB3 的附件导入 Discourse 时，也不得不编写一些 Ruby 的 ` begin rescue end` 包装代码；但最终，我们成功迁移了几乎所有的附件、头像和个人资料图片。

刚开始时，我对 Ruby 和 Rails 毫无经验；但现在，多亏了 Discourse，我成了 Ruby 和 Rails 的忠实粉丝，并且每天都会编写一些 Rails 代码。

如果你有这方面的兴趣，我认为在迁移过程中学习一点相关知识是有益的。

---

<div class="post-metadata">

**Author:** ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)\
**Post date:** [2020年九月16日 09:25 UTC](https://meta.discourse.org/t/vbulletin-5-import-error-invalid-character-in-website-field-and-a-quick-question-about-attachments/161108/5 "2020-09-16T09:25:30Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
