Code review notifications are broken

Copper Contributor

Hi,

We are using Azure DevOps on-premise and for every project I'm working on, I have notifications enabled for Code Reviews changes. The problem is that when I receive the email, it is all broken:

  1. The comments get replace by something like the result of OriginalComment.Replace("\r\n", "<br>")
  2. The date gets an invalid format. From the result, I suppose something like "jjj MM-jj-aaaa hh:mm ss". Note that everything is fine when we open it in the web interface.

My 2 questions:

  1. Is there any template we could modify to fix this?
  2. Is there a setting for notifications date format?

Here is a sample from one of the broken email (Show Source). As you can see, <br> tags are added between each word except where I enter a real line break in the original comment.

 

 

        <div><span>FileUnderReview.vb</span></div>
        <div style=" margin-left: 1em; margin-top: 0.5em; margin-bottom: 0.5em">
          <div style="margin-top: 0.25em; margin-bottom: 0.25em; color: #888"><strong>Bobby Kay</strong><div>Commentaires<br>dans<br>l'autre<br>Code<br>Review</div>jjj 03-jj-aaaa 4:12 04</div>
          <div style="margin-top: 0.25em; margin-bottom: 0.25em; color: #888"><strong>Bobby Kay</strong><div>Je<br>pense<br>pas<br>avoir<br>vu<br>ça<br>avant<br>mais<br>cette<br>ligne<br>pourrait<br>être<br>simplifiée<br>en:
If<br>TypeOf<br>node.FirstNode?.Tag<br>Is<br>PathNodeInfo<br>Then</div>
        Ligne 58 |
      jjj 03-jj-aaaa 4:12 04<div style="border-left: 4px solid #ccc; padding-left: 1em;">
              <div style="margin-top: 0.25em; margin-bottom: 0.25em; color: #888"><strong>John Doe</strong><div>Je<br>dirais<br>raccourci<br>plutôt<br>que<br>simplifiée!<br>Je<br>vais<br>la<br>laisser<br>comme<br>ça<br>pour<br>l'instant</div>jjj 05-jj-aaaa 3:04 03</div>
            </div>
          </div>

 

 

 

 And the same comments in the web UI:

 

 

<div class="flex-grow repos-discussion-thread flex-column flex-grow scroll-hidden"><div class="repos-discussion-comment flex-column has-replies"><div class="flex-column"><div class="flex-row"><div><div class="bolt-coin flex-noshrink repos-comment-header-persona size24 cursor-pointer" data-is-focusable="true" tabindex="0" role="button" aria-label="Bobby Kay"><img class="bolt-coin-content using-image size24" src="http://tfsserver:8080/tfs/site_a/_apis/GraphProfile/MemberAvatars/win.Uy0xLTUtMjEtMTM5MDA2NzM1Ny0xNzcwMDI3MzcyLTE0MTcwMDEzMzMtMTA0MTc3?size=0" alt="Bobby Kay"></div></div><div class="flex-column flex-grow scroll-hidden padding-left-8"><div class="repos-discussion-comment-header flex-row flex-grow flex-center rhythm-horizontal-4 margin-bottom-8"><div class="scroll-hidden flex-row flex-center"><span class="font-weight-semibold padding-right-8 text-ellipsis">Bobby Kay</span><div class="flex-row flex-center rhythm-horizontal-4 margin-left-4"><span class="text-ellipsis" aria-label="18 mars 2020 18 mars 2020 à 16 h 12 HAE"><time class="body-s secondary-text margin-right-4 bolt-time-item white-space-nowrap" datetime="2020-03-18T20:12:07.327Z">18 mars 2020</time></span></div></div><div class="flex-row flex-grow flex-noshrink justify-end flex-center"><button aria-label="Modifier" class="repos-discussion-comment-auto-hide-button bolt-button bolt-icon-button enabled subtle icon-only bolt-focus-treatment" data-focuszone="focuszone-176" data-is-focusable="true" role="button" tabindex="0" type="button"><span aria-hidden="true" class="repos-discussion-comment-auto-hide left-icon flex-noshrink fabric-icon ms-Icon--Edit medium"></span></button><button aria-label="Supprimer" class="repos-discussion-comment-auto-hide-button bolt-button bolt-icon-button enabled subtle icon-only bolt-focus-treatment" data-focuszone="focuszone-176" data-is-focusable="true" role="button" tabindex="-1" type="button"><span aria-hidden="true" class="repos-discussion-comment-auto-hide left-icon flex-noshrink fabric-icon ms-Icon--Delete medium"></span></button><div class="bolt-dropdown-expandable bolt-expandable-button inline-flex-row"><button aria-disabled="false" aria-expanded="false" aria-haspopup="true" class="bolt-button enabled subtle bolt-focus-treatment" data-focuszone="focuszone-176" data-is-focusable="true" role="button" tabindex="-1" type="button"><div class="bolt-dropdown-expandable-button-label justify-start flex-grow text-ellipsis">Actif</div><span aria-hidden="true" class="icon-right font-weight-normal flex-noshrink fabric-icon ms-Icon--ChevronDownMed small"></span></button></div></div></div><div class="markdown-content markdown-editor-preview repos-comment-editor-max-width"><p>Je pense pas avoir vu ça avant mais cette ligne pourrait être simplifiée en:<br>
If TypeOf node.FirstNode?.Tag Is PathNodeInfo Then</p>
</div></div></div></div></div><div class="repos-discussion-comment flex-column"><div class="flex-column"><div class="flex-row"><div><div class="bolt-coin flex-noshrink repos-comment-header-persona size24 cursor-pointer" data-is-focusable="true" tabindex="0" role="button" aria-label="John Doe"><img class="bolt-coin-content using-image size24" src="http://tfsserver:8080/tfs/site_a/_apis/GraphProfile/MemberAvatars/win.Uy0xLTUtMjEtMTM5MDA2NzM1Ny0xNzcwMDI3MzcyLTE0MTcwMDEzMzMtNDI3NTIy?size=0" alt="John Doe"></div></div><div class="flex-column flex-grow scroll-hidden padding-left-8"><div class="repos-discussion-comment-header flex-row flex-grow flex-center rhythm-horizontal-4 margin-bottom-8"><div class="scroll-hidden flex-row flex-center"><span class="font-weight-semibold padding-right-8 text-ellipsis">John Doe</span><div class="flex-row flex-center rhythm-horizontal-4 margin-left-4"><span class="text-ellipsis" aria-label="8 mai 2020 8 mai 2020 à 15 h 04 HAE"><time class="body-s secondary-text margin-right-4 bolt-time-item white-space-nowrap" datetime="2020-05-08T19:04:26.820Z">8 mai 2020</time></span></div></div><div class="flex-row flex-grow flex-noshrink justify-end flex-center"></div></div><div class="markdown-content markdown-editor-preview repos-comment-editor-max-width"><p>Je dirais raccourci plutôt que simplifiée! Je vais la laisser comme ça pour l'instant</p>
</div></div></div></div></div><div class="repos-discussion-thread-reply flex-column"><div class="flex-row flex-grow rhythm-horizontal-8"><div><div class="bolt-coin flex-noshrink margin-right-4 margin-top-4 size24 cursor-pointer" data-is-focusable="true" tabindex="0" role="button" aria-label="Bobby Kay"><img class="bolt-coin-content using-image size24" src="http://tfsserver:8080/tfs/site_a/_apis/GraphProfile/MemberAvatars/win.Uy0xLTUtMjEtMTM5MDA2NzM1Ny0xNzcwMDI3MzcyLTE0MTcwMDEzMzMtMTA0MTc3?size=0" alt="Bobby Kay"></div></div><div class="flex-row flex-grow flex-center rhythm-horizontal-8 repos-comment-editor-max-width"><div class="flex-column flex-grow padding-vertical-4"><div class="bolt-textfield flex-row flex-center focus-treatment"><input autocomplete="off" aria-label="Écrire une réponse..." data-focuszone="focuszone-175" class="bolt-textfield-input flex-grow" id="__bolt-textfield-input-30" placeholder="Écrire une réponse..." tabindex="0" value=""></div></div><button class="bolt-button enabled bolt-focus-treatment" data-focuszone="focuszone-175" data-is-focusable="true" role="button" tabindex="0" type="button">Résoudre</button></div></div></div></div>

 

 

Edit 2022-05-30:

For point #1, I found that the problem seems to come from I found that the problem seems to come from the linefeed2br template in the CodeReviewChangedEvent.xsl file. When I test it with a mock xml, I get the exact same behavior where the spaces (ascii 32) are replaced with <br/> as if they were in fact new lines (ascii x0D, x0A). I replicated the problem using the online parser from W3School.

 

  <xsl:template name="linefeed2br">
    <xsl:param name="StringToTransform"/>
    <xsl:choose>
      <!-- Does the string contain a linefeed? -->
      <xsl:when test="contains($StringToTransform,'
')">
        <!-- find the linefeed and output the substring that comes before it -->
        <xsl:value-of select="substring-before($StringToTransform,'
')"/>
        <!-- remove the line feed and replace with a <br />  -->
        <br/>
        <!-- repeat -->
        <xsl:call-template name="linefeed2br">
          <xsl:with-param name="StringToTransform">
            <xsl:value-of select="substring-after($StringToTransform,'
')"/>
          </xsl:with-param>
        </xsl:call-template>
      </xsl:when>
      <!-- string does not contain newline, so just output it -->
      <xsl:otherwise>
        <xsl:value-of select="$StringToTransform"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

 

What is even weirder is that no matter the character  use (&#10, &#x0D, &#x0A, [real new line]), the space char is always replace and the new line, never.

 

Edit 2022-05-30 #2:

I tested a different online parser, this time from www.freeformatter.com, and this time, it works with &#10 though it was also broken with the real new line. I now have to wait for my server administrator to try this new version of the template to see if it works. I added the 2 files I used. Note that this is a fr-ca regionalized installation.

0 Replies