File tree Expand file tree Collapse file tree 1 file changed +24
-9
lines changed Expand file tree Collapse file tree 1 file changed +24
-9
lines changed Original file line number Diff line number Diff line change @@ -74,15 +74,30 @@ let get_remote_config_json_url filename ?token req =
74
74
end
75
75
76
76
let config_of_content_api_response response =
77
- match response.encoding with
78
- | "base64" ->
79
- Lwt. return
80
- @@ Notabot_j. config_of_string
81
- @@ Base64. decode_string
82
- @@ String. concat
83
- @@ String. split ~on: '\n'
84
- @@ response.content
85
- | e -> remote_config_error " unknown encoding format '%s'" e
77
+ let decode_string_pad s =
78
+ let rec strip_padding i =
79
+ if i < 0 then " "
80
+ else (
81
+ match s.[i] with
82
+ | '=' | '\n' | '\r' | '\t' | ' ' -> strip_padding (i - 1 )
83
+ | _ -> String. sub s ~pos: 0 ~len: (i + 1 )
84
+ )
85
+ in
86
+ Base64. decode_string @@ strip_padding (String. length s - 1 )
87
+ in
88
+ try % lwt
89
+ match response.encoding with
90
+ | "base64" ->
91
+ Lwt. return
92
+ @@ Notabot_j. config_of_string
93
+ @@ decode_string_pad
94
+ @@ String. concat
95
+ @@ String. split_lines
96
+ @@ response.content
97
+ | e -> remote_config_error " unknown encoding format '%s'" e
98
+ with
99
+ | Base64. Invalid_char -> remote_config_error " unable to decode configuration file from base64"
100
+ | Yojson. Json_error msg -> remote_config_error " unable to parse configuration file as valid JSON (%s)" msg
86
101
87
102
let load_config_json url =
88
103
let headers = [ " Accept: application/vnd.github.v3+json" ] in
You can’t perform that action at this time.
0 commit comments