Przeglądaj źródła

fix normalizing base 32 codes and form hints

Daniel Sheffield 1 rok temu
rodzic
commit
554ccb2a5b
2 zmienionych plików z 9 dodań i 5 usunięć
  1. 1 1
      rest/hash_util.py
  2. 8 4
      rest/templates/form-open.tpl

+ 1 - 1
rest/hash_util.py

@@ -100,7 +100,7 @@ def fix_padding(f):
     return wrap
 
 def normalize_base32(_b32: str):
-    return _b32.upper().zfill(DIGEST_SIZE_BYTES*8//5+1)
+    return b32.encode(b32.decode(_b32)).upper().zfill(DIGEST_SIZE_BYTES*8//5+1)
 
 def add_padding_base32(f):
     def wrap(*args, **kwargs):

+ 8 - 4
rest/templates/form-open.tpl

@@ -30,18 +30,22 @@ button[type=submit] {
   <body align="center" style="text-align: center">
       % include('button-style')
       <form id="{{tool}}-open" action="{{action}}" method="{{method}}">
-        <label for="{{tool}}-code"><span>Enter Code</span></label>
+        <label for="{{tool}}-code">
+          <span>Enter<span hidden="true">&nbs;Code</span></span>
+        </label>
         <br/>
         <input
           type="text"
           id="{{tool}}-code"
           name="hash"
-          placeholder="ABC12"
+          placeholder="C0DE"
           required="true"
-          pattern="[A-TV-Za-tv-z0-9]{5}"
+          pattern="[A-TV-Za-tv-z0-9]{1,5}"
+          title="Base32 Code: Any of letters A-Z (excluding U) or digits 0-9.&#10;&#10;Note: O 0 and i I l L 1 can be used interchangeably"
           size="5"
+          style="margin: 0.1em 0 0.3em"
         ></input>
-        <p/>
+        <br/>
         <button class="button-resize pure-button" type="submit" form="{{tool}}-open"> Open </button>
     </form>
   </body>