Changeset View
Changeset View
Standalone View
Standalone View
ui/certificateviewer.cpp
Show First 20 Lines • Show All 57 Lines • ▼ Show 20 Line(s) | |||||
58 | static QString splitDNAttributes(const QStringList &text) | 58 | static QString splitDNAttributes(const QStringList &text) | ||
59 | { | 59 | { | ||
60 | const QStringList attributes = { "C", "CN", "DC", "E", "EMAIL", "EMAILADDRESS", "L", "O", "OU", "PC", "S", "SN", "SP", "ST", "STREET", "T" }; | 60 | const QStringList attributes = { "C", "CN", "DC", "E", "EMAIL", "EMAILADDRESS", "L", "O", "OU", "PC", "S", "SN", "SP", "ST", "STREET", "T" }; | ||
61 | 61 | | |||
62 | for ( const QString &t : text ) | 62 | for ( const QString &t : text ) | ||
63 | { | 63 | { | ||
64 | for ( const QString &attribute : attributes ) | 64 | for ( const QString &attribute : attributes ) | ||
65 | { | 65 | { | ||
66 | const QRegularExpression re( QString( "(.*),\\s*(%1=.*)" ).arg( attribute ), QRegularExpression::DotMatchesEverythingOption ); | 66 | const QRegularExpression re( QStringLiteral( "(.*),\\s*(%1=.*)" ).arg( attribute ), QRegularExpression::DotMatchesEverythingOption ); | ||
67 | const QRegularExpressionMatch match = re.match( t ); | 67 | const QRegularExpressionMatch match = re.match( t ); | ||
68 | if ( match.hasMatch() ) | 68 | if ( match.hasMatch() ) | ||
69 | { | 69 | { | ||
70 | QStringList results = text; | 70 | QStringList results = text; | ||
71 | const int index = results.indexOf( t ); | 71 | const int index = results.indexOf( t ); | ||
72 | results.removeAt( index ); | 72 | results.removeAt( index ); | ||
73 | results.insert( index, match.captured( 2 ) ); | 73 | results.insert( index, match.captured( 2 ) ); | ||
74 | results.insert( index, match.captured( 1 ) ); | 74 | results.insert( index, match.captured( 1 ) ); | ||
75 | return splitDNAttributes( results ); | 75 | return splitDNAttributes( results ); | ||
76 | } | 76 | } | ||
77 | } | 77 | } | ||
78 | } | 78 | } | ||
79 | 79 | | |||
80 | // Clean escaped commas | 80 | // Clean escaped commas | ||
81 | QStringList result = text; | 81 | QStringList result = text; | ||
82 | for ( QString &t : result ) | 82 | for ( QString &t : result ) | ||
83 | { | 83 | { | ||
84 | t.replace( "\\,", "," ); | 84 | t.replace( QLatin1String("\\,"), QLatin1String(",") ); | ||
85 | } | 85 | } | ||
86 | 86 | | |||
87 | // Clean up quoted attributes | 87 | // Clean up quoted attributes | ||
88 | for ( QString &t : result ) | 88 | for ( QString &t : result ) | ||
89 | { | 89 | { | ||
90 | for ( const QString &attribute : attributes ) | 90 | for ( const QString &attribute : attributes ) | ||
91 | { | 91 | { | ||
92 | const QRegularExpression re( QString( "%1=\"(.*)\"" ).arg( attribute ) ); | 92 | const QRegularExpression re( QStringLiteral( "%1=\"(.*)\"" ).arg( attribute ) ); | ||
93 | const QRegularExpressionMatch match = re.match( t ); | 93 | const QRegularExpressionMatch match = re.match( t ); | ||
94 | if ( match.hasMatch() ) | 94 | if ( match.hasMatch() ) | ||
95 | { | 95 | { | ||
96 | t = attribute + "=" + match.captured( 1 ); | 96 | t = attribute + "=" + match.captured( 1 ); | ||
97 | } | 97 | } | ||
98 | } | 98 | } | ||
99 | } | 99 | } | ||
100 | 100 | | |||
▲ Show 20 Lines • Show All 243 Lines • Show Last 20 Lines |