Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EwsUtilities.PATTERN_MONTH and PATTERN_MINUTES compiles same regex into pattern #343

Closed
ashwin244 opened this issue Jun 4, 2015 · 3 comments
Labels

Comments

@ashwin244
Copy link

I was testing the EwsUtilities.java page, while calling the TimeSpan getXSDurationToTimeSpan(String xsDuration) function noticed -

// Month
m = PATTERN_MONTH.matcher(xsDuration);
LOG.debug(m.find());
int month = 0;
if (m.find()) {
  month = Integer.parseInt(m.group().substring(0,
      m.group().indexOf("M")));
}

// Minute
m = PATTERN_MINUTES.matcher(xsDuration);
LOG.debug(m.find());
int minute = 0;
if (m.find()) {
  minute = Integer.parseInt(m.group().substring(0,
      m.group().indexOf("M")));
}

would generate the same value due to the same regular expression compiled into a pattern.
private static final Pattern PATTERN_MONTH = Pattern.compile("(\d+)M");
private static final Pattern PATTERN_MINUTES = Pattern.compile("(\d+)M");

Probably, one of them needs to be changed.

@vbauer
Copy link
Contributor

vbauer commented Jun 4, 2015

Just want to share some information for everybody:
This patterns were used before refactoring of the EwsUtils class (rev.: 3afa991).

@serious6
Copy link
Member

will you provide a PR?

@serious6 serious6 added the bug label Aug 15, 2015
@ghost
Copy link

ghost commented Aug 17, 2015

It seems to be related to #357. All time zone periods with minutes in them are parsed in a wrong way.

  • For example TimeSpan for this one -PT3H30M will be parsed as:
negative true
year 0
month 30
day 0
hour 3
minute 30
seconds 0
  • The big M for months and minutes seems to be correct according to ISO 8601 and the only difference is 'T' in the middle. For example this one P1Y2M10DT2H30M is a correct Time interval.

serious6 added a commit that referenced this issue Aug 30, 2015
Fix: XSDuration in EWSUtilities (#357, #398, #343)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants