浏览代码

Fix: Handle # value in the account name

Neeraj Gupta 1 年之前
父节点
当前提交
ab6867e3b0
共有 1 个文件被更改,包括 10 次插入0 次删除
  1. 10 0
      lib/models/code.dart

+ 10 - 0
lib/models/code.dart

@@ -90,6 +90,7 @@ class Code {
 
   static Code fromRawData(String rawData) {
     Uri uri = Uri.parse(rawData);
+    try {
     return Code(
       _getAccount(uri),
       _getIssuer(uri),
@@ -100,6 +101,15 @@ class Code {
       _getType(uri),
       rawData,
     );
+    } catch(e) {
+      // if account name contains # without encoding,
+      // rest of the url are treated as url fragment
+      if(rawData.contains("#")) {
+        return Code.fromRawData(rawData.replaceAll("#", '%23'));
+      } else {
+        rethrow;
+      }
+    }
   }
 
   static String _getAccount(Uri uri) {