I have a strange UI5 problem. I create a string from a control's binding context which looks like:
Entity('Element%3AInfo%2CID')
Just for info, it looks like this decoded: Entity('Element:Info,ID')
However, I get this String from the following method chain:
oItem.getBindingContext().getPath().substr(1)
So, the whole (pretty basic) "navigate to" block looks like this:
showElement : function (oItem) {
    'use strict';
    var bReplace = jQuery.device.is.phone ? false : true;
    sap.ui.core.UIComponent.getRouterFor(this).navTo("element", {
        from: "master",
        element: oItem.getBindingContext().getPath().substr(1),
        otherpattern: "something"
    }, bReplace);
},
A console log in this block console.log(oItem.getBindingContext().getPath().substr(1)); provides the right string. 
Console output of console.log(oItem.getBindingContext().getPath().substr(1)): Entity('Element%3AInfo%2CID')
The problem is (be aware, this is getting curious) that my URL pattern "{element}" is filled with:
Entity('Element%253AInfo%252CID')
Decoded: Entity('Element%3AInfo%2CID')
As you probably already know, the pattern's "%" is encoded. I don't get why UI5 would do this.
You should also know these facts which I've tested:
- decodeURIComponent(oItem.getBindingContext().getPath().substr(1))leads to "- Entity('Element:Info,ID')"
- encodeURIComponent(oItem.getBindingContext().getPath().substr(1))leads to "- Entity('Element%25253AInfo%25252CID')"
- oItem.getBindingContext().getPath().substr(1).replace("%3A", ":")leads to "- Entity('Element:Info%252CID')"
Is this a bug? I mean the URI pattern is left untouched as long as it doesn't come to a "%". For some odd reason this special character is encoded while everything else doesn't matter.
 
                        
Its not exactly like "%" is getting encoded and everything else is not encoded.
I also came across this issue. SAPUI5 does encoding once, and browser does it second time. Hence in the second iteration you will have only "%" to be encoded.
Initial string :
Element:Info,IDafter first iteration of encoding(by UI5 framework)
encodeURIComponent('Element:Info,ID'): We getElement%3AInfo%2CIDSo for the second iteration, only % is left to be encoded
Element%253AInfo%252CIDhence we get this.So if you are picking up the binding context from URL, you need to decode twice. Else as you are doing once is fine.