Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qurlidna.cpp File Reference
#include "qurl_p.h"
#include <QtCore/qstringlist.h>
#include <QtCore/private/qnumeric_p.h>
#include <QtCore/private/qoffsetstringarray_p.h>
#include <QtCore/private/qstringiterator_p.h>
#include <QtCore/private/qunicodetables_p.h>
#include <algorithm>
+ Include dependency graph for qurlidna.cpp:

Go to the source code of this file.

Functions

static uint encodeDigit (uint digit)
 
static uint adapt (uint delta, uint numpoints, bool firsttime)
 
static void appendEncode (QString *output, uint delta, uint bias)
 
Q_AUTOTEST_EXPORT void qt_punycodeEncoder (QStringView in, QString *output)
 
Q_AUTOTEST_EXPORT QString qt_punycodeDecoder (const QString &pc)
 
static bool lessThan (const QChar *a, int l, const char *c)
 
static bool equal (const QChar *a, int l, const char *b)
 
static bool qt_is_idn_enabled (QStringView aceDomain)
 
template<typename C >
static bool isValidInNormalizedAsciiLabel (C c)
 
template<typename C >
static bool isValidInNormalizedAsciiName (C c)
 
static QString mapDomainName (const QString &in, QUrl::AceProcessingOptions options, bool *resultIsAscii)
 
static bool validateAsciiLabel (QStringView label)
 
static QString convertToAscii (const QString &normalizedDomain, AceLeadingDot dot)
 
static bool checkAsciiDomainName (const QString &normalizedDomain, AceLeadingDot dot, bool *usesPunycode)
 
static QString convertToUnicode (const QString &asciiDomain, QUrl::AceProcessingOptions options)
 
QString qt_ACE_do (const QString &domain, AceOperation op, AceLeadingDot dot, QUrl::AceProcessingOptions options)
 

Variables

static const uint base = 36
 
static const uint tmin = 1
 
static const uint tmax = 26
 
static const uint skew = 38
 
static const uint damp = 700
 
static const uint initial_bias = 72
 
static const uint initial_n = 128
 
static constexpr qsizetype MaxDomainLabelLength = 63
 
static constexpr auto idn_whitelist
 
static Q_CONSTINIT QStringListuser_idn_whitelist = nullptr
 

Function Documentation

◆ adapt()

static uint adapt ( uint  delta,
uint  numpoints,
bool  firsttime 
)
inlinestatic

Definition at line 35 of file qurlidna.cpp.

References base, damp, skew, tmax, and tmin.

Referenced by qt_punycodeDecoder(), and qt_punycodeEncoder().

+ Here is the caller graph for this function:

◆ appendEncode()

static void appendEncode ( QString output,
uint  delta,
uint  bias 
)
inlinestatic

Definition at line 47 of file qurlidna.cpp.

References base, encodeDigit(), output, tmax, and tmin.

Referenced by qt_punycodeEncoder().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkAsciiDomainName()

static bool checkAsciiDomainName ( const QString normalizedDomain,
AceLeadingDot  dot,
bool *  usesPunycode 
)
static

Definition at line 817 of file qurlidna.cpp.

References dot(), ForbidLeadingDot, QString::indexOf(), QString::size(), QStringView::sliced(), QStringView::startsWith(), and validateAsciiLabel().

Referenced by qt_ACE_do().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ convertToAscii()

static QString convertToAscii ( const QString normalizedDomain,
AceLeadingDot  dot 
)
static

Definition at line 780 of file qurlidna.cpp.

References QString::append(), QString::clear(), dot(), ForbidLeadingDot, QString::indexOf(), QString::isEmpty(), qt_punycodeEncoder(), QString::size(), and QStringView::sliced().

Referenced by qt_ACE_do().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ convertToUnicode()

static QString convertToUnicode ( const QString asciiDomain,
QUrl::AceProcessingOptions  options 
)
static

Definition at line 850 of file qurlidna.cpp.

References QString::append(), QString::indexOf(), qt_punycodeDecoder(), QString::size(), and QString::sliced().

Referenced by qt_ACE_do().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ encodeDigit()

static uint encodeDigit ( uint  digit)
inlinestatic

Definition at line 30 of file qurlidna.cpp.

Referenced by appendEncode().

+ Here is the caller graph for this function:

◆ equal()

static bool equal ( const QChar a,
int  l,
const char *  b 
)
static

Definition at line 338 of file qurlidna.cpp.

Referenced by Object::equivalent(), parseHttpOptionHeader(), and qt_is_idn_enabled().

+ Here is the caller graph for this function:

◆ isValidInNormalizedAsciiLabel()

template<typename C >
static bool isValidInNormalizedAsciiLabel ( c)
inlinestatic

Definition at line 379 of file qurlidna.cpp.

Referenced by isValidInNormalizedAsciiName().

+ Here is the caller graph for this function:

◆ isValidInNormalizedAsciiName()

template<typename C >
static bool isValidInNormalizedAsciiName ( c)
inlinestatic

Definition at line 385 of file qurlidna.cpp.

References isValidInNormalizedAsciiLabel().

Referenced by mapDomainName().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ lessThan()

static bool lessThan ( const QChar a,
int  l,
const char *  c 
)
static

Definition at line 321 of file qurlidna.cpp.

References e.

Referenced by QV4::PropertyListPrototype::method_sort(), qt_is_idn_enabled(), QV4::ArrayData::sort(), and QV4::sortHelper().

+ Here is the caller graph for this function:

◆ mapDomainName()

static QString mapDomainName ( const QString in,
QUrl::AceProcessingOptions  options,
bool *  resultIsAscii 
)
static

Definition at line 397 of file qurlidna.cpp.

References QUrl::AceTransitionalProcessing, QUnicodeTables::Deviation, QUnicodeTables::Disallowed, QChar::fromUcs4(), i, QUnicodeTables::idnaMapping(), QUnicodeTables::idnaStatus(), QUnicodeTables::Ignored, isValidInNormalizedAsciiName(), iter, QUnicodeTables::Mapped, Q_LIKELY, and QUnicodeTables::Valid.

Referenced by qt_ACE_do().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ qt_ACE_do()

QString qt_ACE_do ( const QString domain,
AceOperation  op,
AceLeadingDot  dot,
QUrl::AceProcessingOptions  options 
)

Definition at line 889 of file qurlidna.cpp.

References checkAsciiDomainName(), convertToAscii(), convertToUnicode(), dot(), QUrl::IgnoreIDNWhitelist, QString::isEmpty(), mapDomainName(), QString::NormalizationForm_C, qt_is_idn_enabled(), and ToAceOnly.

Referenced by QUrlPrivate::appendHost(), encodeLabel(), QUrl::fromAce(), qDBusInterfaceFromMetaObject(), QUrlPrivate::setHost(), and QUrl::toAce().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ qt_is_idn_enabled()

static bool qt_is_idn_enabled ( QStringView  aceDomain)
static

Definition at line 350 of file qurlidna.cpp.

References equal(), i, idn_whitelist, QStringView::lastIndexOf(), lessThan(), QStringView::mid(), QStringView::size(), and user_idn_whitelist.

Referenced by qt_ACE_do().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ qt_punycodeDecoder()

Q_AUTOTEST_EXPORT QString qt_punycodeDecoder ( const QString pc)

Definition at line 171 of file qurlidna.cpp.

References adapt(), QString::at(), base, QString::fromStdU32String(), i, initial_bias, initial_n, QChar::isSurrogate(), QString::lastIndexOf(), QChar::LastValidCodePoint, MaxDomainLabelLength, QString::mid(), output, qWarning, QString::size(), QString::startsWith(), tmax, tmin, QString::toStdU32String(), and QChar::unicode().

Referenced by convertToUnicode().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ qt_punycodeEncoder()

Q_AUTOTEST_EXPORT void qt_punycodeEncoder ( QStringView  in,
QString output 
)

Definition at line 67 of file qurlidna.cpp.

References adapt(), appendEncode(), d, initial_bias, initial_n, iter, MaxDomainLabelLength, and output.

Referenced by convertToAscii().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ validateAsciiLabel()

static bool validateAsciiLabel ( QStringView  label)
static

Definition at line 469 of file qurlidna.cpp.

References MaxDomainLabelLength.

Referenced by checkAsciiDomainName().

+ Here is the caller graph for this function:

Variable Documentation

◆ base

const uint base = 36
static

Definition at line 20 of file qurlidna.cpp.

Referenced by adapt(), appendEncode(), and qt_punycodeDecoder().

◆ damp

const uint damp = 700
static

Definition at line 24 of file qurlidna.cpp.

Referenced by adapt().

◆ idn_whitelist

constexpr auto idn_whitelist
staticconstexpr

Definition at line 280 of file qurlidna.cpp.

Referenced by QUrl::idnWhitelist(), and qt_is_idn_enabled().

◆ initial_bias

const uint initial_bias = 72
static

Definition at line 25 of file qurlidna.cpp.

Referenced by qt_punycodeDecoder(), and qt_punycodeEncoder().

◆ initial_n

const uint initial_n = 128
static

Definition at line 26 of file qurlidna.cpp.

Referenced by qt_punycodeDecoder(), and qt_punycodeEncoder().

◆ MaxDomainLabelLength

constexpr qsizetype MaxDomainLabelLength = 63
staticconstexpr

Definition at line 28 of file qurlidna.cpp.

Referenced by qt_punycodeDecoder(), qt_punycodeEncoder(), and validateAsciiLabel().

◆ skew

const uint skew = 38
static

Definition at line 23 of file qurlidna.cpp.

Referenced by adapt().

◆ tmax

const uint tmax = 26
static

◆ tmin

const uint tmin = 1
static

◆ user_idn_whitelist

Q_CONSTINIT QStringList* user_idn_whitelist = nullptr
static

Definition at line 319 of file qurlidna.cpp.

Referenced by QUrl::idnWhitelist(), qt_is_idn_enabled(), and QUrl::setIdnWhitelist().