Commit dea4f52
committed
Fix inconsistent results with using regex matches in decode_raw_saml
After running SAML code in production against a Norwegian IdP in a similar library
, it was found by Jørgen Fjeld <jorgen at veridit.no> that it is unreliable to
check for /^</. This is because the ^ matches any line and not just the first one.
It does not help replacing it with \A (Which is the beginning of the string) as
the zlib compressed data may start with a "<".
The Solution implemented in this patch is to check that the current string is Base64
complient. Because XML can't be Base64 compliant, we check if the string is
base64 encoded and if it isn't we return the string with the assumption that it
is the XML. If it is we try and decode + inflate. This make the function
idempotent and decode_raw_saml(decode_raw_saml(Response)) will yield the correct
result.1 parent c8deef8 commit dea4f52
1 file changed
+24
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
40 | 48 | | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
| 49 | + | |
48 | 50 | | |
49 | | - | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
50 | 57 | | |
51 | 58 | | |
52 | 59 | | |
| |||
63 | 70 | | |
64 | 71 | | |
65 | 72 | | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
66 | 82 | | |
67 | 83 | | |
68 | 84 | | |
| |||
0 commit comments