Re: [mongodb-user] MongoDb 2.0.6. and HTML entities: data loss? Html entities break because Mongo converts all & to &

Showing 1-2 of 2 messages
Re: [mongodb-user] MongoDb 2.0.6. and HTML entities: data loss? Html entities break because Mongo converts all & to & Hannes Magnusson 8/10/12 2:27 AM
On Thu, Aug 9, 2012 at 9:44 PM, morningtime <mkoen...@gmail.com> wrote:
> Hi, I'm importing a UTF8 feed into MongoDb. It contains special characters
> such as á, í, ó, but also html encoded etities such as "&copy;" or "&reg;"
> etc.
>
> MongoDb 2.0.6 does this to me on a save() run throuhg PHP 5.4 with the
> official MongoDb driver:
>
> Source: "Bose&reg;"
> Saved in MongoDb as: "Bose&amp;reg;" (broken html!)
>
> Source: "Bose®"
> Saved in MongoDb as: "Bose®" (correct)
>
> Why does MongoDb do this? Why does it convert all & into &amp;, even for
> entities like &copy; -> &amp;copy; (broken html) ?


I cannot reproduce this..
$ cat entity.php
<?php
$m = new Mongo();

$m->test->entities->insert(array("v" => "Bose&reg;"), array("safe" => true));
var_dump($m->test->entities->findOne());
?>
$ php entity.php
array(2) {
  ["_id"]=>
  object(MongoId)#6 (1) {
    ["$id"]=>
    string(24) "5024d38e44415ed07b000000"
  }
  ["v"]=>
  string(9) "Bose&reg;"
}

How does your code look like?

-Hannes
Re: [mongodb-user] MongoDb 2.0.6. and HTML entities: data loss? Html entities break because Mongo converts all & to &amp; Sammaye 8/10/12 2:50 AM
Are you sure your not double encoding anywhere? I also cannot reproduce this, when I saw it on SO and here I tried quite hard to see if the PHP driver did this but I too failed to get a reproduction.


--
You received this message because you are subscribed to the Google
Groups "mongodb-user" group.
To post to this group, send email to mongod...@googlegroups.com
To unsubscribe from this group, send email to
mongodb-user...@googlegroups.com
See also the IRC channel -- freenode.net#mongodb