Changeset View
Changeset View
Standalone View
Standalone View
src/irc/server.cpp
Show First 20 Lines • Show All 729 Lines • ▼ Show 20 Line(s) | 729 | { | |||
---|---|---|---|---|---|
730 | QStringList requestCaps; | 730 | QStringList requestCaps; | ||
731 | QStringList capsList = availableCaps.split (QChar(' '), QString::SkipEmptyParts); | 731 | QStringList capsList = availableCaps.split (QChar(' '), QString::SkipEmptyParts); | ||
732 | QStringList nameValue; | 732 | QStringList nameValue; | ||
733 | 733 | | |||
734 | foreach(const QString &cap, capsList) | 734 | foreach(const QString &cap, capsList) | ||
735 | { | 735 | { | ||
736 | nameValue = cap.split(QChar('=')); | 736 | nameValue = cap.split(QChar('=')); | ||
737 | 737 | | |||
738 | if(nameValue[0] == QLatin1String("sasl")) | 738 | if (nameValue.isEmpty()) | ||
739 | continue; | ||||
740 | | ||||
741 | if(nameValue.at(0) == QLatin1String("sasl")) | ||||
739 | { | 742 | { | ||
740 | QString authCommand; | 743 | QString authCommand; | ||
741 | 744 | | |||
742 | if (getIdentity()) { | 745 | if (getIdentity()) { | ||
743 | // A username is optional SASL EXTERNAL and a client cert substitutes | 746 | // A username is optional SASL EXTERNAL and a client cert substitutes | ||
744 | // for the password. | 747 | // for the password. | ||
745 | if (getIdentity()->getAuthType() == QLatin1String("saslexternal")) { | 748 | if (getIdentity()->getAuthType() == QLatin1String("saslexternal")) { | ||
746 | authCommand = QStringLiteral("EXTERNAL"); | 749 | authCommand = QStringLiteral("EXTERNAL"); | ||
747 | // PLAIN on the other hand requires both. | 750 | // PLAIN on the other hand requires both. | ||
748 | } else if (getIdentity()->getAuthType() == QLatin1String("saslplain") | 751 | } else if (getIdentity()->getAuthType() == QLatin1String("saslplain") | ||
749 | && !getIdentity()->getSaslAccount().isEmpty() | 752 | && !getIdentity()->getSaslAccount().isEmpty() | ||
750 | && !getIdentity()->getAuthPassword().isEmpty()) { | 753 | && !getIdentity()->getAuthPassword().isEmpty()) { | ||
751 | authCommand = QStringLiteral("PLAIN"); | 754 | authCommand = QStringLiteral("PLAIN"); | ||
752 | } | 755 | } | ||
753 | } | 756 | } | ||
754 | 757 | | |||
755 | if(!authCommand.isEmpty()) | 758 | if(!authCommand.isEmpty()) | ||
756 | { | 759 | { | ||
757 | QSet<QString> supportedSaslTypes; | 760 | QStringList supportedSaslTypes; | ||
761 | if(nameValue.size() > 1) | ||||
762 | supportedSaslTypes = nameValue.at(1).split(QChar(',')); | ||||
758 | 763 | | |||
759 | if(nameValue.count() > 1) | 764 | supportedSaslTypes.removeDuplicates(); | ||
760 | supportedSaslTypes = QSet<QString>::fromList(nameValue[1].split(QChar(','))); | | |||
761 | 765 | | |||
762 | if(!supportedSaslTypes.isEmpty() && !supportedSaslTypes.contains(authCommand)) | 766 | if(!supportedSaslTypes.isEmpty() && !supportedSaslTypes.contains(authCommand)) | ||
763 | getStatusView()->appendServerMessage(i18n("Error"), i18n("Server does not support %1 as SASL authentication mechanism, skipping SASL authentication.", authCommand)); | 767 | getStatusView()->appendServerMessage(i18n("Error"), i18n("Server does not support %1 as SASL authentication mechanism, skipping SASL authentication.", authCommand)); | ||
764 | else | 768 | else | ||
765 | requestCaps.append (QStringLiteral("sasl")); | 769 | requestCaps.append (QStringLiteral("sasl")); | ||
766 | } | 770 | } | ||
767 | } | 771 | } | ||
768 | else if(m_capabilityNames.contains(nameValue[0])) | 772 | else if(m_capabilityNames.contains(nameValue.at(0))) | ||
769 | { | 773 | { | ||
770 | requestCaps.append (nameValue[0]); | 774 | requestCaps.append (nameValue.at(0)); | ||
771 | } | 775 | } | ||
772 | 776 | | |||
773 | // HACK: twitch.tv's IRC server doesn't handle WHO so | 777 | // HACK: twitch.tv's IRC server doesn't handle WHO so | ||
774 | // let's disable all WHO requests for servers that has | 778 | // let's disable all WHO requests for servers that has | ||
775 | // twitch.tv capabilities | 779 | // twitch.tv capabilities | ||
776 | if(nameValue[0].startsWith("twitch.tv")) | 780 | if(nameValue.at(0).startsWith("twitch.tv")) | ||
777 | { | 781 | { | ||
778 | m_whoRequestsDisabled = true; | 782 | m_whoRequestsDisabled = true; | ||
779 | } | 783 | } | ||
780 | } | 784 | } | ||
781 | 785 | | |||
782 | if(!requestCaps.isEmpty()) | 786 | if(!requestCaps.isEmpty()) | ||
783 | { | 787 | { | ||
784 | QString capsString = requestCaps.join(QLatin1Char(' ')); | 788 | QString capsString = requestCaps.join(QLatin1Char(' ')); | ||
▲ Show 20 Lines • Show All 3664 Lines • Show Last 20 Lines |