Commit f3aa90a
Simon Coffey
Clarify ISO 8601 duration regexp
The ISO 8601 parsing regexp is moderately complex, and uses numbered
backreferences to extract data, which is prone to breakage if new
capture groups are introduced (either inadvertently or deliberately).
This also means every regexp group we don't want to capture must be
anonymised using (?: ...).
In modern rubies we could use named capture groups to clarify things;
however since these are only supported since ruby 1.9 and ruby-saml
supports 1.8.7, that's not an option.
However, we can still use /x to introduce whitespace and source code
comments, which this commit does, splitting each meaningful capture
group onto its own annotated line.
Doing this, it also became clear that some of the groups weren't
necessary, e.g. the two groups surrounding each part of the ( YMDHMS
format | week format) disjunction, so I've reduced the nesting somewhat,
too.1 parent c9f81b9 commit f3aa90a
1 file changed
+17
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
19 | 33 | | |
20 | 34 | | |
21 | 35 | | |
| |||
37 | 51 | | |
38 | 52 | | |
39 | 53 | | |
40 | | - | |
| 54 | + | |
41 | 55 | | |
42 | 56 | | |
43 | | - | |
| 57 | + | |
44 | 58 | | |
45 | 59 | | |
46 | 60 | | |
| |||
0 commit comments