Unescape not replacing - bug?

I’m processing an incoming roster and running into some issues with the JID. One thing I noticed is that it takes what comes in through the roster IQ, takes each item and during the process it escapes the incoming JID value. (Roster.as line 270 item.jid is escaping the value from myXML which is already escaped) Since this is coming in “over the wire” and inside XML shouldn’t it know that it’s already escaped? In my case what I see in the xml is \40 because the @ symbol is escaped. This winds up being \5c40 because the escape is finding the \ before the 40.

Then I looked at the unescape code and something seems weird. In the unescape code is checking to see if something is present with double backslash “\5c” and “\40” but then replacing with only a single backslash as in /\5c/g and /\40/g (AbstractJID::unescapedNode). The end result that I see when I expand unescaped to escaped, then to unescaped and so on is a buildup of 5c. I attached a file with the starting xml and a sequence of escape & unescape to show the buildup of 5c in the object. I would expect a sequence like this to toggle between two values.
So is this a bug?
EscapeAndUnescape.txt.zip (484 Bytes)