<html>
<body>
<div style="font-family: Verdana, Arial, Helvetica, Sans-Serif;">
<table bgcolor="#f9f3c9" width="100%" cellpadding="8" style="border: 1px #c9c399 solid;">
<tr>
<td>
This is an automatically generated e-mail. To reply, visit:
<a href="http://git.reviewboard.kde.org/r/106083/">http://git.reviewboard.kde.org/r/106083/</a>
</td>
</tr>
</table>
<br />
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
<p style="margin-top: 0;">On September 2nd, 2012, 12:04 a.m. UTC, <b>Nikita Skovoroda</b> wrote:</p>
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
<table width="100%" border="0" bgcolor="white" style="border: 1px solid #C0C0C0; border-collapse: collapse; margin: 2px padding: 2px;">
<thead>
<tr>
<th colspan="4" bgcolor="#F0F0F0" style="border-bottom: 1px solid #C0C0C0; font-size: 9pt; padding: 4px 8px; text-align: left;">
<a href="http://git.reviewboard.kde.org/r/106083/diff/1/?file=78685#file78685line47" style="color: black; font-weight: bold; text-decoration: underline;">filters/youtube/youtube-filter.cpp</a>
<span style="font-weight: normal;">
(Diff revision 1)
</span>
</th>
</tr>
</thead>
<tbody>
<tr>
<th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
<td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
<th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">47</font></th>
<td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "> <span class="s">"src=</span><span class="se">\"</span><span class="s">http://www.youtube.com/embed/%1</span><span class="se">\"</span><span class="s"> "</span></pre></td>
</tr>
</tbody>
</table>
<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">The %1 = url.queryItemValue(QLatin1String("v")) is not escaped here, and can contain ",<,> symbols (and any other complex html).
Don't forget that queryItemValue decodes percent-encoded strings.</pre>
</blockquote>
<p>On September 2nd, 2012, 9:27 p.m. UTC, <b>Nikita Skovoroda</b> wrote:</p>
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">I'd make a separate variable for the link and escape it using KUrl.
Crude example follows:
html template:
…iframe src=\"%1\"…
url:
KUrl frameUrl(QLatin1String("http://www.youtube.com/embed/%1").arg(id));
inserting the url into the html template:
.arg(QString::fromAscii(frameUrl.toEncoded()))
Or something like that. That should fix things.</pre>
</blockquote>
<p>On September 3rd, 2012, 7:49 a.m. UTC, <b>Nikita Skovoroda</b> wrote:</p>
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">I missed one thing: ID can contain something like percent-encoded "../html5" string, and http://www.youtube.com/html5 would open inside the iframe in this case. That's not good, either.
Maybe it would be better to just pass the id through QUrl::toPercentEncoding and use the original template, but you need to specify what symbols to keep depending on how you extracted the id.
If the id was extracted using queryItemValue, then you want just to encode everything (because it decodes everything that was previosly encoded).
If the id was extracted using a regexp, then you probably wish to keep the % symbols (because you don't want to do double-encoding in case if it's already done).</pre>
</blockquote>
</blockquote>
<pre style="margin-left: 1em; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">I added a check to make sure the video id matches a regex for a valid video id. That way nothing can creep in masquerading as a video id.</pre>
<br />
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
<p style="margin-top: 0;">On September 2nd, 2012, 12:04 a.m. UTC, <b>Nikita Skovoroda</b> wrote:</p>
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
<table width="100%" border="0" bgcolor="white" style="border: 1px solid #C0C0C0; border-collapse: collapse; margin: 2px padding: 2px;">
<thead>
<tr>
<th colspan="4" bgcolor="#F0F0F0" style="border-bottom: 1px solid #C0C0C0; font-size: 9pt; padding: 4px 8px; text-align: left;">
<a href="http://git.reviewboard.kde.org/r/106083/diff/1/?file=78685#file78685line54" style="color: black; font-weight: bold; text-decoration: underline;">filters/youtube/youtube-filter.cpp</a>
<span style="font-weight: normal;">
(Diff revision 1)
</span>
</th>
</tr>
</thead>
<tbody>
<tr>
<th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
<td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
<th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">54</font></th>
<td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "> <span class="k">if</span> <span class="p">(</span><span class="n">url</span><span class="p">.</span><span class="n">host</span><span class="p">()</span> <span class="o">==</span> <span class="n">QLatin1String</span><span class="p">(</span><span class="s">"www.youtube.com"</span><span class="p">))</span> <span class="p">{</span></pre></td>
</tr>
</tbody>
</table>
<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">What happens to http://youtube.com/watch?v=someid ?</pre>
</blockquote>
<p>On September 2nd, 2012, 11:46 a.m. UTC, <b>Nikita Skovoroda</b> wrote:</p>
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Another possible format: http://youtu.be/someid , this is equivalent to http://www.youtube.com/watch?v=someid</pre>
</blockquote>
<p>On September 2nd, 2012, 9:27 p.m. UTC, <b>Nikita Skovoroda</b> wrote:</p>
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">You could add an array/list of structs, for example:
{
QString urlRegexp; // Url for matching and extracting the video id
QString urlSubstitute; // Url for embedding, for example, iframe url
QString html; // The html template that contains the code that needs to be embeded.
}
This way, it would be easy to support different video hosting services and several possible prefixes for each one.
For example, youtube would have:
urlRegexp = "^(?:https?://)?(?:www\.)(?:youtube\.com/watch.*[&\?]v=|youtu\.be/)([^&]+)" // Or something like that, i haven't checked this one, written down without testing.
urlSubstitute = "http://www.youtube.com/embed/%1"
html = "…iframe src=\"%1\"…" // Your html, it's too big to include it here.</pre>
</blockquote>
<p>On September 3rd, 2012, 6:45 a.m. UTC, <b>Nikita Skovoroda</b> wrote:</p>
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Forgot an «?» after «(?:www\.)»:
urlRegexp = "^(?:https?://)?(?:www\.)?(?:youtube\.com/watch.*[&\?]v=|youtu\.be/)([^&]+)"</pre>
</blockquote>
<p>On September 3rd, 2012, 7:49 a.m. UTC, <b>Nikita Skovoroda</b> wrote:</p>
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">My wrong, separation of urlSubstitute and html parameters is not needed, because the video id can be encoded separately as described above.
So, the whole thing could just be a QMap(fromRegex => toHtmlTemplate).</pre>
</blockquote>
</blockquote>
<pre style="margin-left: 1em; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">At this stage I don't want to support youtube.be, although I did add a check for youtube.com (without the www) URLs.
The usecase for this plugin is when you copy-paste the video of a URL that you are watching to a friend. Since youtube _allways_ expands to http://www.youtube.com/, there's no point in supporting the former two.</pre>
<br />
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
<p style="margin-top: 0;">On September 2nd, 2012, 12:04 a.m. UTC, <b>Nikita Skovoroda</b> wrote:</p>
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
<table width="100%" border="0" bgcolor="white" style="border: 1px solid #C0C0C0; border-collapse: collapse; margin: 2px padding: 2px;">
<thead>
<tr>
<th colspan="4" bgcolor="#F0F0F0" style="border-bottom: 1px solid #C0C0C0; font-size: 9pt; padding: 4px 8px; text-align: left;">
<a href="http://git.reviewboard.kde.org/r/106083/diff/1/?file=78685#file78685line58" style="color: black; font-weight: bold; text-decoration: underline;">filters/youtube/youtube-filter.cpp</a>
<span style="font-weight: normal;">
(Diff revision 1)
</span>
</th>
</tr>
</thead>
<tbody>
<tr>
<th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
<td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
<th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">58</font></th>
<td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "> <span class="n">message</span><span class="p">.</span><span class="n">appendMessagePart</span><span class="p">(</span><span class="n">html</span><span class="p">.</span><span class="n">arg</span><span class="p">(</span><span class="n">url</span><span class="p">.</span><span class="n">queryItemValue</span><span class="p">(</span><span class="n">QLatin1String</span><span class="p">(</span><span class="s">"v"</span><span class="p">))));</span></pre></td>
</tr>
</tbody>
</table>
<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">What happens if «v» parameter is empty?</pre>
</blockquote>
<p>On September 2nd, 2012, 9:27 p.m. UTC, <b>Nikita Skovoroda</b> wrote:</p>
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Parsing the url with regular expressions (see above) would solve this with no extra code involved.</pre>
</blockquote>
</blockquote>
<pre style="margin-left: 1em; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">it won't match the regex.</pre>
<br />
<p>- Lasath</p>
<br />
<p>On September 11th, 2012, 10:19 p.m. UTC, Lasath Fernando wrote:</p>
<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="8" style="background-image: url('http://git.reviewboard.kde.org/static/rb/images/review_request_box_top_bg.ab6f3b1072c9.png'); background-position: left top; background-repeat: repeat-x; border: 1px black solid;">
<tr>
<td>
<div>Review request for Telepathy.</div>
<div>By Lasath Fernando.</div>
<p style="color: grey;"><i>Updated Sept. 11, 2012, 10:19 p.m.</i></p>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Description </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
<tr>
<td>
<pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Right, so here's a big fat review containing many many things, including all the remaining plugins and a few tweaks to Message.
As per usual, all the code is in my scratch repo: http://quickgit.kde.org/index.php?p=clones%2Fktp-text-ui%2Ffernando%2Fgsoc.git&a=summary
Now, I'm going to take a well earned nap.</pre>
</td>
</tr>
</table>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Testing </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
<tr>
<td>
<pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Wrote/passed/failed unit tests; talked to myself so much to the point I swear I have mild schizophrenia now. </pre>
</td>
</tr>
</table>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Diffs</b> </h1>
<ul style="margin-left: 3em; padding-left: 0;">
<li>filters/CMakeLists.txt <span style="color: grey">(ee7c23d)</span></li>
<li>filters/bugzilla/CMakeLists.txt <span style="color: grey">(PRE-CREATION)</span></li>
<li>filters/bugzilla/bugzilla-filter.h <span style="color: grey">(PRE-CREATION)</span></li>
<li>filters/bugzilla/bugzilla-filter.cpp <span style="color: grey">(PRE-CREATION)</span></li>
<li>filters/bugzilla/ktptextui_message_filter_bugzilla.desktop <span style="color: grey">(PRE-CREATION)</span></li>
<li>filters/highlight/CMakeLists.txt <span style="color: grey">(PRE-CREATION)</span></li>
<li>filters/highlight/highlight-filter.h <span style="color: grey">(PRE-CREATION)</span></li>
<li>filters/highlight/highlight-filter.cpp <span style="color: grey">(PRE-CREATION)</span></li>
<li>filters/highlight/ktptextui_message_filter_highlight.desktop <span style="color: grey">(PRE-CREATION)</span></li>
<li>filters/latex/CMakeLists.txt <span style="color: grey">(PRE-CREATION)</span></li>
<li>filters/latex/ktp_message_filter_latex_converter.sh <span style="color: grey">(PRE-CREATION)</span></li>
<li>filters/latex/ktptextui_message_filter_latex.desktop <span style="color: grey">(PRE-CREATION)</span></li>
<li>filters/latex/latex-filter.h <span style="color: grey">(PRE-CREATION)</span></li>
<li>filters/latex/latex-filter.cpp <span style="color: grey">(PRE-CREATION)</span></li>
<li>filters/pipes/CMakeLists.txt <span style="color: grey">(PRE-CREATION)</span></li>
<li>filters/pipes/kcm_ktp_filter_config_pipes.desktop <span style="color: grey">(PRE-CREATION)</span></li>
<li>filters/pipes/ktptextui_message_filter_pipes.desktop <span style="color: grey">(PRE-CREATION)</span></li>
<li>filters/pipes/pipes-config.h <span style="color: grey">(PRE-CREATION)</span></li>
<li>filters/pipes/pipes-config.cpp <span style="color: grey">(PRE-CREATION)</span></li>
<li>filters/pipes/pipes-config.ui <span style="color: grey">(PRE-CREATION)</span></li>
<li>filters/pipes/pipes-delegate.h <span style="color: grey">(PRE-CREATION)</span></li>
<li>filters/pipes/pipes-delegate.cpp <span style="color: grey">(PRE-CREATION)</span></li>
<li>filters/pipes/pipes-filter.h <span style="color: grey">(PRE-CREATION)</span></li>
<li>filters/pipes/pipes-filter.cpp <span style="color: grey">(PRE-CREATION)</span></li>
<li>filters/pipes/pipes-model.h <span style="color: grey">(PRE-CREATION)</span></li>
<li>filters/pipes/pipes-model.cpp <span style="color: grey">(PRE-CREATION)</span></li>
<li>filters/pipes/pipes-prefs.h <span style="color: grey">(PRE-CREATION)</span></li>
<li>filters/pipes/pipes-prefs.cpp <span style="color: grey">(PRE-CREATION)</span></li>
<li>filters/pipes/pipes-prefstest.h <span style="color: grey">(PRE-CREATION)</span></li>
<li>filters/pipes/pipes-prefstest.cpp <span style="color: grey">(PRE-CREATION)</span></li>
<li>filters/substitution/CMakeLists.txt <span style="color: grey">(PRE-CREATION)</span></li>
<li>filters/substitution/kcm_ktp_filter_config_substitution.desktop <span style="color: grey">(PRE-CREATION)</span></li>
<li>filters/substitution/ktptextui_message_filter_substitution.desktop <span style="color: grey">(PRE-CREATION)</span></li>
<li>filters/substitution/substitution-config.h <span style="color: grey">(PRE-CREATION)</span></li>
<li>filters/substitution/substitution-config.cpp <span style="color: grey">(PRE-CREATION)</span></li>
<li>filters/substitution/substitution-config.ui <span style="color: grey">(PRE-CREATION)</span></li>
<li>filters/substitution/substitution-filter.h <span style="color: grey">(PRE-CREATION)</span></li>
<li>filters/substitution/substitution-filter.cpp <span style="color: grey">(PRE-CREATION)</span></li>
<li>filters/substitution/substitution-prefs.h <span style="color: grey">(PRE-CREATION)</span></li>
<li>filters/substitution/substitution-prefs.cpp <span style="color: grey">(PRE-CREATION)</span></li>
<li>filters/youtube/CMakeLists.txt <span style="color: grey">(PRE-CREATION)</span></li>
<li>filters/youtube/ktptextui_message_filter_youtube.desktop <span style="color: grey">(PRE-CREATION)</span></li>
<li>filters/youtube/youtube-filter.h <span style="color: grey">(PRE-CREATION)</span></li>
<li>filters/youtube/youtube-filter.cpp <span style="color: grey">(PRE-CREATION)</span></li>
<li>lib/abstract-message-filter.h <span style="color: grey">(7b60d48)</span></li>
<li>lib/abstract-message-filter.cpp <span style="color: grey">(2a3a897)</span></li>
<li>lib/message.h <span style="color: grey">(ef9530b)</span></li>
<li>lib/message.cpp <span style="color: grey">(6db648e)</span></li>
<li>tests/message-processor-basic-tests.h <span style="color: grey">(7dc99e4)</span></li>
<li>tests/message-processor-basic-tests.cpp <span style="color: grey">(8546605)</span></li>
</ul>
<p><a href="http://git.reviewboard.kde.org/r/106083/diff/" style="margin-left: 3em;">View Diff</a></p>
</td>
</tr>
</table>
</div>
</body>
</html>