~launchpad-pqm/launchpad/devel

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
= Question messages =

Question messages are plain text. They are formatted as HTML for web
pages. Many messages originate from emails where unwanted or
unnecessary content is included. Note: This set of tests is generally
the same rules as xx-bug-comments-truncated.txt; changes here may
require changes to that test.

Let's have an authenticated user create a message in the style of
an email post to examine the markup rules. This message contains a
quoted passage, and a signature with an email address in it.

    >>> user_browser.open('http://answers.launchpad.dev/ubuntu/+question/11')
    >>> print user_browser.title.decode('utf-8')
    Question #11 : ...

    >>> user_browser.getControl('Message').value = (
    ...     "Top quoting is bad netiquette.\n"
    ...     "The leading text will be displayed\n"
    ...     "normally--no markup to hide it from view.\n"
    ...     "\n"
    ...     "Somebody said sometime ago:\n"
    ...     "> 1. Remove the letters  c, j, q, x, w\n"
    ...     ">    from the English Language.\n"
    ...     "> 2. Remove the penny from US currency.\n"
    ...     "\n"
    ...     "--\n"
    ...     "______________________\n"
    ...     "human@somewhere.org\n"
    ...     "Witty signatures rock!\n")
    >>> user_browser.getControl('Add Information Request').click()


== Email addresses are only shown to authenticated users ==

Email addresses are visible to authenticated users. Sample Person is
authenticated already, He will see 'human@somewhere.org'

    >>> print user_browser.title.decode('utf-8')
    Question #11 :  ...
    >>> text = find_tags_by_class(
    ...     user_browser.contents, 'boardCommentBody')[-1]
    >>> print extract_text(text.findAll('p')[-1])
    --
    ______________________
    human@somewhere.org
    Witty signatures rock!

Unauthenticated users, such as a bot will see the mock email address
of 'person@domain.dom'. The anonymous user is unauthenticated, he will
see the obfuscated email address (<email address hidden>).

    >>> anon_browser.open('http://answers.launchpad.dev/ubuntu/+question/11')
    >>> print anon_browser.title
    Question #11 : ...

    >>> text = find_tags_by_class(
    ...     anon_browser.contents, 'boardCommentBody')[-1]
    >>> print extract_text(text.findAll('p')[-1])
    --
    ______________________
    &lt;email address hidden&gt;
    Witty signatures rock!


== Signatures and quoted passages are hidden ==

The style and script in the user_browser control the display and
behaviour of content inside tags with the class 'foldable'. The script
adds a link to toggle the display of the foldable text between none
and inline.

Signatures are identified by paragraphs with a starting line like '--'.
The entire content of the paragraph is wrapped by a tag of 'foldable'
class.

    >>> # XXX sinzui 2007-06-14 bug 120425
    >>> # Pagetests cannot test CSS and JS behaviour.
    >>> # We can only check that the markup includes the hooks
    >>> # for the style and script.
    >>> print text.findAll('p')[-1]
    <p><span class="foldable">--...
    &lt;email address hidden&gt;<br />
    Witty signatures rock!
    </span></p>

Quoted passages are identified by lines that start with '>', '|', ':'.
The lines represents many paragraphs of quoted text, but we mark the
block of content as a single paragraph. The quoted lines are often
preceded by a citation line. Only the quoted lines are wrapped with a
tag of 'foldable' class, citation lines are always displayed. Again
we can continue with the anonymous user to see the markup.

    >>> print text.findAll('p')[-2]
    <p>Somebody said sometime ago:<br />
    <span class="foldable-quoted">
    &gt; 1. Remove the letters  c, j, q, x, w<br />
    &gt;    from the English Language.<br />
    &gt; 2. Remove the penny from US currency.
    </span></p>