diff options
author | socialgraph <socialgraph@yandex-team.com> | 2022-08-10 10:20:58 +0300 |
---|---|---|
committer | socialgraph <socialgraph@yandex-team.com> | 2022-08-10 10:20:58 +0300 |
commit | 07163912675dd114719ec1090ae095355b51ad75 (patch) | |
tree | f1565a4d1ebbf8897749ff2425c14d79ebf43c19 /library | |
parent | a1b5c2e7f704c40f99d96b1df8ccdb75b05a40df (diff) | |
download | ydb-07163912675dd114719ec1090ae095355b51ad75.tar.gz |
ui32 not enough for features flag
Так как добавил новый флаг, отвечающий за оставление хэшбенга, то Feature флаги перестали помещаться в свои прежние 32 бита, то везде поменял long на ui64
Diffstat (limited to 'library')
-rw-r--r-- | library/cpp/http/fetch/httpload.cpp | 6 | ||||
-rw-r--r-- | library/cpp/uri/assign.cpp | 16 | ||||
-rw-r--r-- | library/cpp/uri/common.cpp | 2 | ||||
-rw-r--r-- | library/cpp/uri/common.h | 23 | ||||
-rw-r--r-- | library/cpp/uri/location.cpp | 2 | ||||
-rw-r--r-- | library/cpp/uri/uri.cpp | 2 | ||||
-rw-r--r-- | library/cpp/uri/uri.h | 10 |
7 files changed, 31 insertions, 30 deletions
diff --git a/library/cpp/http/fetch/httpload.cpp b/library/cpp/http/fetch/httpload.cpp index 82ea8900b5..f3f6c5245e 100644 --- a/library/cpp/http/fetch/httpload.cpp +++ b/library/cpp/http/fetch/httpload.cpp @@ -211,7 +211,7 @@ bool httpLoadAgent::startRequest(const char* url, URL_.Clear(); PersistentConn_ = persistent; - long flags = THttpURL::FeatureSchemeKnown | THttpURL::FeaturesNormalizeSet; + ui64 flags = THttpURL::FeatureSchemeKnown | THttpURL::FeaturesNormalizeSet; if (HandleAuthorization_) flags |= THttpURL::FeatureAuthSupported; @@ -231,7 +231,7 @@ bool httpLoadAgent::startRequest(const char* url, URL_.Clear(); PersistentConn_ = persistent; - long flags = THttpURL::FeatureSchemeKnown | THttpURL::FeaturesNormalizeSet; + ui64 flags = THttpURL::FeatureSchemeKnown | THttpURL::FeaturesNormalizeSet; if (HandleAuthorization_) flags |= THttpURL::FeatureAuthSupported; @@ -285,7 +285,7 @@ bool httpLoadAgent::setHost(const char* host_url, URL_.Clear(); PersistentConn_ = true; - long flags = THttpURL::FeatureSchemeKnown | THttpURL::FeaturesNormalizeSet; + ui64 flags = THttpURL::FeatureSchemeKnown | THttpURL::FeaturesNormalizeSet; if (HandleAuthorization_) flags |= THttpURL::FeatureAuthSupported; diff --git a/library/cpp/uri/assign.cpp b/library/cpp/uri/assign.cpp index 97122c445a..dc694baefb 100644 --- a/library/cpp/uri/assign.cpp +++ b/library/cpp/uri/assign.cpp @@ -61,7 +61,7 @@ namespace NUri { // decoding shortens so writing over host in buf is OK TMemoryWriteBuffer out(buf.Get(), buflen); TEncoder decoder(out, FeatureDecodeANY | FeatureToLower); - const long outFlags = decoder.ReEncode(host); + const ui64 outFlags = decoder.ReEncode(host); hasExtended = 0 != (outFlags & FeatureEncodeExtendedASCII); // check again @@ -106,7 +106,7 @@ namespace NUri { TStringBuf TUri::HostToAscii(const TStringBuf& host, TMallocPtr<char>& buf, bool allowIDN, ECharset enc) { // find what we have - long haveFlags = 0; + ui64 haveFlags = 0; for (size_t i = 0; i != host.length(); ++i) { haveFlags |= TEncoder::GetFlags(host[i]).FeatFlags; } @@ -124,7 +124,7 @@ namespace NUri { return outHost; } - static inline bool AppendField(TMemoryWriteBuffer& out, TField::EField field, const TStringBuf& value, long flags) { + static inline bool AppendField(TMemoryWriteBuffer& out, TField::EField field, const TStringBuf& value, ui64 flags) { if (value.empty()) { return false; } @@ -158,7 +158,7 @@ namespace NUri { // special processing for fields const bool convertIDN = parser.Flags & FeatureConvertHostIDN; - long flags = parser.Flags.Allow; + ui64 flags = parser.Flags.Allow; if (convertIDN) { flags |= FeatureAllowHostIDN | FeatureCheckHost; } @@ -271,7 +271,7 @@ namespace NUri { char* beg = out.Buf(); TStringBuf value = section.Get(); - long careFlags = section.GetFlagsEncode(); + ui64 careFlags = section.GetFlagsEncode(); if (field == FieldQuery) { if (queryEscapedFragment.IsInited()) { @@ -279,7 +279,7 @@ namespace NUri { if (!queryEscapedFragment.empty()) { ReEncodeToField( out, queryEscapedFragment, - FieldQuery, FeatureDecodeANY | careFlags, + FieldQuery, FeatureDecodeANY | careFlags, FieldFrag, FeatureDecodeANY | parser.GetFieldFlags(FieldFrag) ); } @@ -322,9 +322,9 @@ namespace NUri { FldSetNoDirty(field, TStringBuf(beg, end)); // special character case - const long checkChars = section.GetFlagsAllPlaintext() & FeaturesCheckSpecialChar; + const ui64 checkChars = section.GetFlagsAllPlaintext() & FeaturesCheckSpecialChar; if (0 != checkChars) { // has unencoded special chars: check permission - const long allowChars = parser.GetFieldFlags(field) & checkChars; + const ui64 allowChars = parser.GetFieldFlags(field) & checkChars; if (checkChars != allowChars) { status = ParsedBadFormat; } diff --git a/library/cpp/uri/common.cpp b/library/cpp/uri/common.cpp index 05af1e57d1..5bcb2fc38b 100644 --- a/library/cpp/uri/common.cpp +++ b/library/cpp/uri/common.cpp @@ -4,7 +4,7 @@ #include <util/generic/singleton.h> namespace NUri { - static_assert(TFeature::FeatureMAX <= sizeof(unsigned long) * 8, "expect TFeature::FeatureMAX <= sizeof(unsigned long) * 8"); + static_assert(TFeature::FeatureMAX <= sizeof(ui64) * 8, "expect TFeature::FeatureMAX <= sizeof(ui64) * 8"); const TSchemeInfo TSchemeInfo::Registry[] = { TSchemeInfo(TScheme::SchemeEmpty, TStringBuf()), // scheme is empty and inited diff --git a/library/cpp/uri/common.h b/library/cpp/uri/common.h index 8025357763..27c559a55b 100644 --- a/library/cpp/uri/common.h +++ b/library/cpp/uri/common.h @@ -30,6 +30,7 @@ namespace NUri { FIELD_NAME(Path), FIELD_NAME(Query), FIELD_NAME(Frag), + FIELD_NAME(HashBang), // add fields above FieldUrlMAX, @@ -121,7 +122,7 @@ namespace NUri { #define FEATURE_NAME(f) _BitFeature##f #define FEATURE_FLAG_NAME(f) Feature##f -#define FEATURE_FLAG(f) FEATURE_FLAG_NAME(f) = 1UL << FEATURE_NAME(f) +#define FEATURE_FLAG(f) FEATURE_FLAG_NAME(f) = 1ULL << FEATURE_NAME(f) protected: enum EBit { @@ -251,19 +252,15 @@ namespace NUri { // internal usage: decode all encoded symbols FEATURE_NAME(DecodeANY), + // move and encode #! fragment after the query + FEATURE_NAME(FragmentToHashBang), + // add before this line _FeatureMAX }; - protected: - enum EPrivate : ui32 { - FEATURE_FLAG(DecodeANY), - FEATURE_FLAG(DecodeFieldAllowed), - FEATURE_FLAG(DecodeStandardExtra), - }; - public: - enum EPublic : ui32 { + enum EPublic : ui64 { FeatureMAX = _FeatureMAX, FEATURE_FLAG(AuthSupported), FEATURE_FLAG(SchemeKnown), @@ -283,6 +280,7 @@ namespace NUri { FEATURE_FLAG(DecodeExtendedDelim), FEATURE_FLAG(EncodeCntrl), FEATURE_FLAG(EncodePercent), + FEATURE_FLAG(FragmentToHashBang), FEATURE_FLAG(HashBangToEscapedFragment), FEATURE_FLAG(EscapedToHashBangFragment), FEATURE_FLAG(PathDenyRootParent), @@ -296,6 +294,9 @@ namespace NUri { FEATURE_FLAG(NoRelPath), FEATURE_FLAG_NAME(HierURI) = FEATURE_FLAG_NAME(NoRelPath), FEATURE_FLAG(UpperEncoded), + FEATURE_FLAG(DecodeANY), + FEATURE_FLAG(DecodeFieldAllowed), + FEATURE_FLAG(DecodeStandardExtra), }; #undef FEATURE_NAME @@ -303,7 +304,7 @@ namespace NUri { public: //============================== - enum ESets { + enum ESets : ui64 { // these are guaranteed and will change buffer size FeatureDecodeStandard = 0 | FeatureDecodeUnreserved | FeatureDecodeStandardExtra, @@ -442,7 +443,7 @@ namespace NUri { #define FEATURE_NAME(f) _BitFeature##f #define FEATURE_FLAG_NAME(f) Feature##f -#define FEATURE_FLAG(f) FEATURE_FLAG_NAME(f) = 1UL << FEATURE_NAME(f) +#define FEATURE_FLAG(f) FEATURE_FLAG_NAME(f) = 1ULL << FEATURE_NAME(f) struct TQueryArg { TStringBuf Name; diff --git a/library/cpp/uri/location.cpp b/library/cpp/uri/location.cpp index a6a4d11ffa..c6c0d4b529 100644 --- a/library/cpp/uri/location.cpp +++ b/library/cpp/uri/location.cpp @@ -2,7 +2,7 @@ #include "uri.h" namespace NUri { - static const int URI_PARSE_FLAGS = + static const ui64 URI_PARSE_FLAGS = (TFeature::FeaturesRecommended | TFeature::FeatureConvertHostIDN | TFeature::FeatureEncodeExtendedDelim | TFeature::FeatureEncodePercent) & ~TFeature::FeatureHashBangToEscapedFragment; TString ResolveRedirectLocation(const TStringBuf& baseUrl, diff --git a/library/cpp/uri/uri.cpp b/library/cpp/uri/uri.cpp index 56a9a4e5ef..962e84e7a1 100644 --- a/library/cpp/uri/uri.cpp +++ b/library/cpp/uri/uri.cpp @@ -287,7 +287,7 @@ namespace NUri { /********************************************************/ TUri::TLinkType TUri::Normalize(const TUri& base, - const TStringBuf& link, const TStringBuf& codebase, long careFlags, ECharset enc) { + const TStringBuf& link, const TStringBuf& codebase, ui64 careFlags, ECharset enc) { // parse URL if (ParsedOK != ParseImpl(link, careFlags, 0, SchemeEmpty, enc)) return LinkIsBad; diff --git a/library/cpp/uri/uri.h b/library/cpp/uri/uri.h index 3b6c19fe4a..71fc687fc2 100644 --- a/library/cpp/uri/uri.h +++ b/library/cpp/uri/uri.h @@ -19,7 +19,7 @@ namespace NUri { /********************************************************/ class TUri - : public TFeature, + : public TFeature, public TField, public TScheme, public TState { @@ -354,7 +354,7 @@ namespace NUri { void Merge(const TUri& base, int correctAbs = -1); - TLinkType Normalize(const TUri& base, const TStringBuf& link, const TStringBuf& codebase = TStringBuf(), long careFlags = FeaturesDefault, ECharset enc = CODES_UTF8); + TLinkType Normalize(const TUri& base, const TStringBuf& link, const TStringBuf& codebase = TStringBuf(), ui64 careFlags = FeaturesDefault, ECharset enc = CODES_UTF8); private: int PrintFlags(int flags) const { @@ -543,15 +543,15 @@ namespace NUri { return LinkIsGlobal; } - static IOutputStream& ReEncodeField(IOutputStream& out, const TStringBuf& val, EField fld, long flags = FeaturesEncodeDecode) { + static IOutputStream& ReEncodeField(IOutputStream& out, const TStringBuf& val, EField fld, ui64 flags = FeaturesEncodeDecode) { return NEncode::TEncoder::ReEncode(out, val, NEncode::TEncodeMapper(flags, fld)); } - static IOutputStream& ReEncodeToField(IOutputStream& out, const TStringBuf& val, EField srcfld, long srcflags, EField dstfld, long dstflags) { + static IOutputStream& ReEncodeToField(IOutputStream& out, const TStringBuf& val, EField srcfld, ui64 srcflags, EField dstfld, ui64 dstflags) { return NEncode::TEncoder::ReEncodeTo(out, val, NEncode::TEncodeMapper(srcflags, srcfld), NEncode::TEncodeToMapper(dstflags, dstfld)); } - static IOutputStream& ReEncode(IOutputStream& out, const TStringBuf& val, long flags = FeaturesEncodeDecode) { + static IOutputStream& ReEncode(IOutputStream& out, const TStringBuf& val, ui64 flags = FeaturesEncodeDecode) { return ReEncodeField(out, val, FieldAllMAX, flags); } |