hash_util: Show error if url is invalid.

For urls we cannot handle, we inform user via a nice
error message.

See comment in decodeHashComponent for some of the cases it
fixes for us.
This commit is contained in:
Aman Agrawal
2020-07-10 20:16:59 +05:30
committed by Tim Abbott
parent f97d35ebd2
commit c32f27a05d
2 changed files with 26 additions and 2 deletions

View File

@@ -56,7 +56,18 @@ exports.encode_stream_name = function (operand) {
};
exports.decodeHashComponent = function (str) {
return decodeURIComponent(str.replace(/\./g, '%'));
try {
// This fails for URLS containing
// foo.foo or foo%foo due to our fault in special handling
// of such characters when encoding. This can also,
// fail independent of our fault, so just tell the user
// that the url is invalid.
// TODO: Show possible valid urls to the user.
return decodeURIComponent(str.replace(/\./g, '%'));
} catch (e) {
ui_report.error(i18n.t("Invalid URL"), undefined, $("#home-error"), 2000);
return "";
}
};
exports.decode_operand = function (operator, operand) {