~ci-train-bot/signon-ui/signon-ui-ubuntu-zesty-2608

« back to all changes in this revision

Viewing changes to src/browser-request.cpp

  • Committer: CI Train Bot
  • Author(s): Alberto Mardegan
  • Date: 2015-11-25 16:34:09 UTC
  • mfrom: (141.1.1 url-slash-1173926)
  • Revision ID: ci-train-bot@canonical.com-20151125163409-jvkrs1013lfwa2s6
Strip trailing "/" when comparing URLs

Fixes an issue arising when our callback URL is http://example.com and we get redirected to http://example.com/ Fixes: #1173926

Show diffs side-by-side

added added

removed removed

Lines of Context:
76
76
static const QString keyAllowedSchemes = QString("AllowedSchemes");
77
77
static const QString keyIgnoreSslErrors = QString("IgnoreSslErrors");
78
78
 
 
79
static bool pathsAreEqual(const QString &p1, const QString &p2)
 
80
{
 
81
    static QRegExp regExp("/*$");
 
82
    QString p1copy(p1);
 
83
    QString p2copy(p2);
 
84
    return p1copy.remove(regExp) == p2copy.remove(regExp);
 
85
}
 
86
 
79
87
class WebPage: public QWebPage
80
88
{
81
89
    Q_OBJECT
128
136
         * If this behaviour is not desired for some requests, then just avoid
129
137
         * calling setFinalUrl() */
130
138
        if (url.host() == m_finalUrl.host() &&
131
 
            url.path() == m_finalUrl.path()) {
 
139
            pathsAreEqual(url.path(), m_finalUrl.path())) {
132
140
            Q_EMIT finalUrlReached(url);
133
141
            return false;
134
142
        }
337
345
    m_failTimer.stop();
338
346
 
339
347
    if (url.host() == finalUrl.host() &&
340
 
        url.path() == finalUrl.path()) {
 
348
        pathsAreEqual(url.path(), finalUrl.path())) {
341
349
        responseUrl = url;
342
350
        if (q->embeddedUi() || !m_dialog->isVisible()) {
343
351
            /* Do not show the notification page. */