Changeset - 494c793cc160
[Not reviewed]
default
0 2 0
Thomas De Schampheleire - 8 years ago 2018-02-12 09:34:17
thomas.de_schampheleire@nokia.com
lib: change ' to ' to satisfy Outlook HTML rendering

The HTML entity ' (') did not exist in the HTML 4 spec [1] and was only
added later.
As Outlook (and Thunderbird) uses an old engine to render HTML and CSS, it does
not recognize this entity and treats it as a literal string.

Therefore, use the equivalent ' code which should be recognized by all
browsers, even those restricted to HTML 4.

[1] https://www.w3.org/TR/html4/sgml/entities.html
2 files changed with 8 insertions and 8 deletions:
0 comments (0 inline, 0 general)
kallithea/lib/helpers.py
Show inline comments
 
@@ -64,49 +64,49 @@ def canonical_url(*args, **kargs):
 
        kargs['qualified'] = True
 
    return url(*args, **kargs)
 

	
 

	
 
def canonical_hostname():
 
    '''Return canonical hostname of system'''
 
    from kallithea import CONFIG
 
    try:
 
        parts = CONFIG.get('canonical_url', '').split('://', 1)
 
        return parts[1].split('/', 1)[0]
 
    except IndexError:
 
        parts = url('home', qualified=True).split('://', 1)
 
        return parts[1].split('/', 1)[0]
 

	
 

	
 
def html_escape(s):
 
    """Return string with all html escaped.
 
    This is also safe for javascript in html but not necessarily correct.
 
    """
 
    return (s
 
        .replace('&', '&')
 
        .replace(">", ">")
 
        .replace("<", "&lt;")
 
        .replace('"', "&quot;")
 
        .replace("'", "&apos;")
 
        .replace("'", "&#39;") # some mail readers use HTML 4 and doesn't support &apos;
 
        )
 

	
 
def js(value):
 
    """Convert Python value to the corresponding JavaScript representation.
 

	
 
    This is necessary to safely insert arbitrary values into HTML <script>
 
    sections e.g. using Mako template expression substitution.
 

	
 
    Note: Rather than using this function, it's preferable to avoid the
 
    insertion of values into HTML <script> sections altogether. Instead,
 
    data should (to the extent possible) be passed to JavaScript using
 
    data attributes or AJAX calls, eliminating the need for JS specific
 
    escaping.
 

	
 
    Note: This is not safe for use in attributes (e.g. onclick), because
 
    quotes are not escaped.
 

	
 
    Because the rules for parsing <script> varies between XHTML (where
 
    normal rules apply for any special characters) and HTML (where
 
    entities are not interpreted, but the literal string "</script>"
 
    is forbidden), the function ensures that the result never contains
 
    '&', '<' and '>', thus making it safe in both those contexts (but
 
    not in attributes).
 
    """
kallithea/tests/models/test_dump_html_mails.ref.html
Show inline comments
 
@@ -73,49 +73,49 @@ View Comment: http://comment.org
 
                    <td>
 
<table cellpadding="0" cellspacing="0" border="0" width="100%">
 
    <tr>
 
        <td>
 
<table cellpadding="0" cellspacing="0" width="100%" border="0" bgcolor="#f9f9f9" style="border:1px solid #ddd;border-radius:4px">
 
    <tr>
 
        <td height="10px" style="height:10px" colspan="3"></td>
 
    </tr>
 
    <tr>
 
        <td width="20px" style="width:20px"></td>
 
        <td>
 
            <div style="font-weight:600;color:#395fa0">Opinionated User (jsmith)</div>
 
        </td>
 
        <td width="20px" style="width:20px"></td>
 
    </tr>
 
    <tr>
 
        <td height="10px" style="height:10px" colspan="3" style="border-bottom:1px solid #ddd"></td>
 
    </tr>
 
    <tr>
 
        <td height="10px" style="height:10px" colspan="3"></td>
 
    </tr>
 
    <tr>
 
        <td width="20px" style="width:20px"></td>
 
        <td>
 
            <div style="font-family:Lucida Console,Consolas,Monaco,Inconsolata,Liberation Mono,monospace;white-space:pre-wrap"><div class="formatted-fixed">This is the new &apos;comment&apos;.<br/><br/> - and here it ends indented.</div></div>
 
            <div style="font-family:Lucida Console,Consolas,Monaco,Inconsolata,Liberation Mono,monospace;white-space:pre-wrap"><div class="formatted-fixed">This is the new &#39;comment&#39;.<br/><br/> - and here it ends indented.</div></div>
 
        </td>
 
        <td width="20px" style="width:20px"></td>
 
    </tr>
 
    <tr>
 
        <td height="10px" style="height:10px" colspan="3"></td>
 
    </tr>
 
</table>
 
        </td>
 
    </tr>
 
    <tr>
 
        <td height="30px" style="height:30px"></td>
 
    </tr>
 
    <tr>
 
        <td>
 
            <div>
 
                Changeset on
 
                <a style="color:#395fa0;text-decoration:none"
 
                   href="http://example.com/repo_target">http://example.com/repo_target</a>
 
                branch
 
                <span style="color:#395fa0">brunch</span>:
 
            </div>
 
            <div>
 
                "<a style="color:#395fa0;text-decoration:none"
 
                   href="http://changeset.com">This changeset did something clever which is hard to explain</a>"
 
@@ -232,49 +232,49 @@ View Comment: http://comment.org
 
                    <td>
 
<table cellpadding="0" cellspacing="0" border="0" width="100%">
 
    <tr>
 
        <td>
 
<table cellpadding="0" cellspacing="0" width="100%" border="0" bgcolor="#f9f9f9" style="border:1px solid #ddd;border-radius:4px">
 
    <tr>
 
        <td height="10px" style="height:10px" colspan="3"></td>
 
    </tr>
 
    <tr>
 
        <td width="20px" style="width:20px"></td>
 
        <td>
 
            <div style="font-weight:600;color:#395fa0">Opinionated User (jsmith)</div>
 
        </td>
 
        <td width="20px" style="width:20px"></td>
 
    </tr>
 
    <tr>
 
        <td height="10px" style="height:10px" colspan="3" style="border-bottom:1px solid #ddd"></td>
 
    </tr>
 
    <tr>
 
        <td height="10px" style="height:10px" colspan="3"></td>
 
    </tr>
 
    <tr>
 
        <td width="20px" style="width:20px"></td>
 
        <td>
 
            <div style="font-family:Lucida Console,Consolas,Monaco,Inconsolata,Liberation Mono,monospace;white-space:pre-wrap"><div class="formatted-fixed">This is the new &apos;comment&apos;.<br/><br/> - and here it ends indented.</div></div>
 
            <div style="font-family:Lucida Console,Consolas,Monaco,Inconsolata,Liberation Mono,monospace;white-space:pre-wrap"><div class="formatted-fixed">This is the new &#39;comment&#39;.<br/><br/> - and here it ends indented.</div></div>
 
        </td>
 
        <td width="20px" style="width:20px"></td>
 
    </tr>
 
    <tr>
 
        <td height="10px" style="height:10px" colspan="3"></td>
 
    </tr>
 
</table>
 
        </td>
 
    </tr>
 
    <tr>
 
        <td height="30px" style="height:30px"></td>
 
    </tr>
 
    <tr>
 
        <td>
 
            <div>
 
                Changeset on
 
                <a style="color:#395fa0;text-decoration:none"
 
                   href="http://example.com/repo_target">http://example.com/repo_target</a>
 
                branch
 
                <span style="color:#395fa0">brunch</span>:
 
            </div>
 
            <div>
 
                "<a style="color:#395fa0;text-decoration:none"
 
                   href="http://changeset.com">This changeset did something clever which is hard to explain</a>"
 
@@ -409,49 +409,49 @@ View Comment: http://comment.org
 
        <td height="10px" style="height:10px" colspan="3" style="border-bottom:1px solid #ddd"></td>
 
    </tr>
 
        <tr>
 
            <td height="10px" style="height:10px" colspan="3"></td>
 
        </tr>
 
        <tr>
 
            <td width="20px" style="width:20px"></td>
 
            <td>
 
                    <div style="font-weight:600">
 
                        Status change:
 
                        Approved
 
                    </div>
 
            </td>
 
            <td width="20px" style="width:20px"></td>
 
        </tr>
 
        <tr>
 
            <td height="10px" style="height:10px" colspan="3" style="border-bottom:1px solid #ddd"></td>
 
        </tr>
 
    <tr>
 
        <td height="10px" style="height:10px" colspan="3"></td>
 
    </tr>
 
    <tr>
 
        <td width="20px" style="width:20px"></td>
 
        <td>
 
            <div style="font-family:Lucida Console,Consolas,Monaco,Inconsolata,Liberation Mono,monospace;white-space:pre-wrap"><div class="formatted-fixed">This is the new &apos;comment&apos;.<br/><br/> - and here it ends indented.</div></div>
 
            <div style="font-family:Lucida Console,Consolas,Monaco,Inconsolata,Liberation Mono,monospace;white-space:pre-wrap"><div class="formatted-fixed">This is the new &#39;comment&#39;.<br/><br/> - and here it ends indented.</div></div>
 
        </td>
 
        <td width="20px" style="width:20px"></td>
 
    </tr>
 
    <tr>
 
        <td height="10px" style="height:10px" colspan="3"></td>
 
    </tr>
 
</table>
 
        </td>
 
    </tr>
 
    <tr>
 
        <td height="30px" style="height:30px"></td>
 
    </tr>
 
    <tr>
 
        <td>
 
            <div>
 
                Changeset on
 
                <a style="color:#395fa0;text-decoration:none"
 
                   href="http://example.com/repo_target">http://example.com/repo_target</a>
 
                branch
 
                <span style="color:#395fa0">brunch</span>:
 
            </div>
 
            <div>
 
                "<a style="color:#395fa0;text-decoration:none"
 
                   href="http://changeset.com">This changeset did something clever which is hard to explain</a>"
 
@@ -586,49 +586,49 @@ View Comment: http://comment.org
 
        <td height="10px" style="height:10px" colspan="3" style="border-bottom:1px solid #ddd"></td>
 
    </tr>
 
        <tr>
 
            <td height="10px" style="height:10px" colspan="3"></td>
 
        </tr>
 
        <tr>
 
            <td width="20px" style="width:20px"></td>
 
            <td>
 
                    <div style="font-weight:600">
 
                        Status change:
 
                        Approved
 
                    </div>
 
            </td>
 
            <td width="20px" style="width:20px"></td>
 
        </tr>
 
        <tr>
 
            <td height="10px" style="height:10px" colspan="3" style="border-bottom:1px solid #ddd"></td>
 
        </tr>
 
    <tr>
 
        <td height="10px" style="height:10px" colspan="3"></td>
 
    </tr>
 
    <tr>
 
        <td width="20px" style="width:20px"></td>
 
        <td>
 
            <div style="font-family:Lucida Console,Consolas,Monaco,Inconsolata,Liberation Mono,monospace;white-space:pre-wrap"><div class="formatted-fixed">This is the new &apos;comment&apos;.<br/><br/> - and here it ends indented.</div></div>
 
            <div style="font-family:Lucida Console,Consolas,Monaco,Inconsolata,Liberation Mono,monospace;white-space:pre-wrap"><div class="formatted-fixed">This is the new &#39;comment&#39;.<br/><br/> - and here it ends indented.</div></div>
 
        </td>
 
        <td width="20px" style="width:20px"></td>
 
    </tr>
 
    <tr>
 
        <td height="10px" style="height:10px" colspan="3"></td>
 
    </tr>
 
</table>
 
        </td>
 
    </tr>
 
    <tr>
 
        <td height="30px" style="height:30px"></td>
 
    </tr>
 
    <tr>
 
        <td>
 
            <div>
 
                Changeset on
 
                <a style="color:#395fa0;text-decoration:none"
 
                   href="http://example.com/repo_target">http://example.com/repo_target</a>
 
                branch
 
                <span style="color:#395fa0">brunch</span>:
 
            </div>
 
            <div>
 
                "<a style="color:#395fa0;text-decoration:none"
 
                   href="http://changeset.com">This changeset did something clever which is hard to explain</a>"
 
@@ -707,49 +707,49 @@ Subject: Test Message
 
    <tr>
 
        <td height="20px" style="height:20px" colspan="3"></td>
 
    </tr>
 
    <tr>
 
        <td width="30px" style="width:30px"></td>
 
        <td style="font-family:Helvetica,Arial,sans-serif;font-size:19px;line-height:24px">
 
            <span style="font-weight:600;color:#395fa0">Message</span>
 
        </td>
 
        <td width="30px" style="width:30px"></td>
 
    </tr>
 
    <tr>
 
        <td height="20px" style="height:20px" colspan="3"></td>
 
    </tr>
 
</table>
 
                    </td>
 
                </tr>
 
                <tr>
 
                    <td height="30px" style="height:30px" colspan="3"></td>
 
                </tr>
 
                <tr>
 
                    <td></td>
 
                    <td>
 
<table cellpadding="0" cellspacing="0" border="0" width="100%">
 
    <tr>
 
        <td style="font-family:Lucida Console,Consolas,Monaco,Inconsolata,Liberation Mono,monospace;white-space:pre-wrap"><div class="formatted-fixed">This is the &apos;body&apos; of the &quot;test&quot; message<br/> - nothing interesting here except indentation.</div></td>
 
        <td style="font-family:Lucida Console,Consolas,Monaco,Inconsolata,Liberation Mono,monospace;white-space:pre-wrap"><div class="formatted-fixed">This is the &#39;body&#39; of the &quot;test&quot; message<br/> - nothing interesting here except indentation.</div></td>
 
    </tr>
 
</table>
 
                    </td>
 
                    <td></td>
 
                </tr>
 
                <tr>
 
                    <td height="30px" style="height:30px" colspan="3"></td>
 
                </tr>
 
            </table>
 
        </td>
 
        <td width="30px" style="width:30px"></td>
 
    </tr>
 
</table>
 
<!--/body-->
 
<!--/html-->
 
<hr/>
 
<hr/>
 
<h1>registration</h1>
 
<pre>
 
From: u1
 
To: u2@example.com
 
Subject: New user newbie registered
 
</pre>
 
<hr/>
 
@@ -966,49 +966,49 @@ View Pull Request: http://pr.org/7
 
                   href="http://mainline.com/repo">http://mainline.com/repo</a>
 
                at
 
                <span style="color:#395fa0">trunk</span>:
 
            </div>
 
            <div>
 
                <a style="color:#395fa0;text-decoration:none"
 
                   href="http://pr.org/7">#7</a>
 
                "<span style="color:#395fa0">The Title</span>"
 
                by
 
                <span style="color:#395fa0">u2 u3 (u2)</span>.
 
            </div>
 
        </td>
 
    </tr>
 
    <tr><td height="10px" style="height:10px"></td></tr>
 
    <tr>
 
        <td>
 
            <div>
 
                Description:
 
            </div>
 
        </td>
 
    </tr>
 
    <tr><td height="10px" style="height:10px"></td></tr>
 
    <tr>
 
        <td>
 
            <div style="font-family:Lucida Console,Consolas,Monaco,Inconsolata,Liberation Mono,monospace;white-space:pre-wrap;color:#395fa0"><div class="formatted-fixed">This PR is &apos;awesome&apos; because it does &lt;stuff&gt;<br/> - please approve indented!</div></div>
 
            <div style="font-family:Lucida Console,Consolas,Monaco,Inconsolata,Liberation Mono,monospace;white-space:pre-wrap;color:#395fa0"><div class="formatted-fixed">This PR is &#39;awesome&#39; because it does &lt;stuff&gt;<br/> - please approve indented!</div></div>
 
        </td>
 
    </tr>
 
    <tr><td height="15px" style="height:15px"></td></tr>
 
    <tr>
 
        <td>
 
            <div>Changesets:</div>
 
        </td>
 
    </tr>
 
    <tr><td height="10px" style="height:10px"></td></tr>
 

	
 
    <tr>
 
        <td style="font-family:Helvetica,Arial,sans-serif">
 
            <ul style="color:#395fa0;padding-left:15px;margin:0">
 
                    <li style="mso-special-format:bullet">
 
                        <a style="color:#395fa0;text-decoration:none"
 
                           href="http://changeset_home/?repo_name=repo_org&amp;revision=123abc123abc123abc123abc123abc123abc123abc">
 
                            Introduce one and two
 
                        </a>
 
                    </li>
 
                    <li style="mso-special-format:bullet">
 
                        <a style="color:#395fa0;text-decoration:none"
 
                           href="http://changeset_home/?repo_name=repo_org&amp;revision=567fed567fed567fed567fed567fed567fed567fed">
 
                            Make one plus two equal tree
 
                        </a>
 
@@ -1141,49 +1141,49 @@ View Pull Request: http://pr.org/7
 
                   href="http://mainline.com/repo">http://mainline.com/repo</a>
 
                at
 
                <span style="color:#395fa0">trunk</span>:
 
            </div>
 
            <div>
 
                <a style="color:#395fa0;text-decoration:none"
 
                   href="http://pr.org/7">#7</a>
 
                "<span style="color:#395fa0">The Title</span>"
 
                by
 
                <span style="color:#395fa0">u2 u3 (u2)</span>.
 
            </div>
 
        </td>
 
    </tr>
 
    <tr><td height="10px" style="height:10px"></td></tr>
 
    <tr>
 
        <td>
 
            <div>
 
                Description:
 
            </div>
 
        </td>
 
    </tr>
 
    <tr><td height="10px" style="height:10px"></td></tr>
 
    <tr>
 
        <td>
 
            <div style="font-family:Lucida Console,Consolas,Monaco,Inconsolata,Liberation Mono,monospace;white-space:pre-wrap;color:#395fa0"><div class="formatted-fixed">This PR is &apos;awesome&apos; because it does &lt;stuff&gt;<br/> - please approve indented!</div></div>
 
            <div style="font-family:Lucida Console,Consolas,Monaco,Inconsolata,Liberation Mono,monospace;white-space:pre-wrap;color:#395fa0"><div class="formatted-fixed">This PR is &#39;awesome&#39; because it does &lt;stuff&gt;<br/> - please approve indented!</div></div>
 
        </td>
 
    </tr>
 
    <tr><td height="15px" style="height:15px"></td></tr>
 
    <tr>
 
        <td>
 
            <div>Changesets:</div>
 
        </td>
 
    </tr>
 
    <tr><td height="10px" style="height:10px"></td></tr>
 

	
 
    <tr>
 
        <td style="font-family:Helvetica,Arial,sans-serif">
 
            <ul style="color:#395fa0;padding-left:15px;margin:0">
 
                    <li style="mso-special-format:bullet">
 
                        <a style="color:#395fa0;text-decoration:none"
 
                           href="http://changeset_home/?repo_name=repo_org&amp;revision=123abc123abc123abc123abc123abc123abc123abc">
 
                            Introduce one and two
 
                        </a>
 
                    </li>
 
                    <li style="mso-special-format:bullet">
 
                        <a style="color:#395fa0;text-decoration:none"
 
                           href="http://changeset_home/?repo_name=repo_org&amp;revision=567fed567fed567fed567fed567fed567fed567fed">
 
                            Make one plus two equal tree
 
                        </a>
0 comments (0 inline, 0 general)