mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-21 06:45:39 -06:00
Core: UrlDecode option not to convert + to space, UrlEncode now converts space to %20, CtrlCore: Gtk files clip fixed
This commit is contained in:
parent
fbeef84f75
commit
1e4974dc8b
4 changed files with 33 additions and 30 deletions
|
|
@ -7,9 +7,9 @@ String MIMECharsetName(byte charset);
|
|||
String UrlEncode(const char *s, const char *end);
|
||||
String UrlEncode(const char *s, int len);
|
||||
String UrlEncode(const String& s);
|
||||
String UrlDecode(const char *s, const char *end);
|
||||
String UrlDecode(const char *s, int len);
|
||||
String UrlDecode(const String& s);
|
||||
String UrlDecode(const char *s, const char *end, bool plus_is_space = true);
|
||||
String UrlDecode(const char *s, int len, bool plus_is_space = true);
|
||||
String UrlDecode(const String& s, bool plus_is_space = true);
|
||||
|
||||
String QPEncode(const char* s);
|
||||
String QPDecode(const char *s, bool undescore_to_space = false);
|
||||
|
|
|
|||
|
|
@ -119,10 +119,7 @@ String UrlEncode(const char *p, const char *e)
|
|||
out.Cat(b, int(p - b));
|
||||
if(p >= e)
|
||||
break;
|
||||
if(*p == ' ')
|
||||
out << '+';
|
||||
else
|
||||
out << '%' << hex_digits[(*p >> 4) & 15] << hex_digits[*p & 15];
|
||||
out << '%' << hex_digits[(*p >> 4) & 15] << hex_digits[*p & 15];
|
||||
}
|
||||
return String(out);
|
||||
}
|
||||
|
|
@ -137,12 +134,12 @@ String UrlEncode(const String& s)
|
|||
return UrlEncode(~s, s.GetLength());
|
||||
}
|
||||
|
||||
String UrlDecode(const char *b, const char *e)
|
||||
String UrlDecode(const char *b, const char *e, bool plus_is_space)
|
||||
{
|
||||
StringBuffer out;
|
||||
byte d1, d2, d3, d4;
|
||||
for(const char *p = b; p < e; p++)
|
||||
if(*p == '+')
|
||||
if(*p == '+' && plus_is_space)
|
||||
out.Cat(' ');
|
||||
else if(*p == '%' && (d1 = ctoi(p[1])) < 16 && (d2 = ctoi(p[2])) < 16) {
|
||||
out.Cat(d1 * 16 + d2);
|
||||
|
|
@ -159,14 +156,14 @@ String UrlDecode(const char *b, const char *e)
|
|||
return String(out);
|
||||
}
|
||||
|
||||
String UrlDecode(const char *s, int len)
|
||||
String UrlDecode(const char *s, int len, bool plus_is_space)
|
||||
{
|
||||
return UrlDecode(s, s + len);
|
||||
return UrlDecode(s, s + len, plus_is_space);
|
||||
}
|
||||
|
||||
String UrlDecode(const String& s)
|
||||
String UrlDecode(const String& s, bool plus_is_space)
|
||||
{
|
||||
return UrlDecode(~s, s.GetLength());
|
||||
return UrlDecode(~s, s.GetLength(), plus_is_space);
|
||||
}
|
||||
|
||||
String QPEncode(const char* s)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
topic "Internet utility";
|
||||
[2 $$0,0#00000000000000000000000000000000:Default]
|
||||
[i448;a25;kKO9;2 $$1,0#37138531426314131252341829483380:class]
|
||||
[l288;2 $$2,2#27521748481378242620020725143825:desc]
|
||||
[0 $$3,0#96390100711032703541132217272105:end]
|
||||
|
|
@ -9,6 +8,7 @@ topic "Internet utility";
|
|||
[l288;i1121;b17;O9;~~~.1408;2 $$7,0#10431211400427159095818037425705:param]
|
||||
[i448;b42;O9;2 $$8,8#61672508125594000341940100500538:tparam]
|
||||
[b42;2 $$9,9#13035079074754324216151401829390:normal]
|
||||
[2 $$0,0#00000000000000000000000000000000:Default]
|
||||
[{_}
|
||||
[ {{10000@(113.42.0) [s0;%% [*@7;4 Internet format utility functions]]}}&]
|
||||
[s3; &]
|
||||
|
|
@ -46,14 +46,20 @@ space is represented by `'`+`' and anything else as %HH, where
|
|||
HH is two digit hexadecimal number.&]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:UrlDecode`(const char`*`,const char`*`): [_^String^ String]_[* UrlDecode]([@(0.0.255) c
|
||||
onst]_[@(0.0.255) char]_`*[*@3 s], [@(0.0.255) const]_[@(0.0.255) char]_`*[*@3 end])&]
|
||||
[s5;:UrlDecode`(const char`*`,int`): [_^String^ String]_[* UrlDecode]([@(0.0.255) const]_[@(0.0.255) c
|
||||
har]_`*[*@3 s], [@(0.0.255) int]_[*@3 len])&]
|
||||
[s5;:UrlDecode`(const String`&`): [_^String^ String]_[* UrlDecode]([@(0.0.255) const]_[_^String^ S
|
||||
tring][@(0.0.255) `&]_[*@3 s])&]
|
||||
[s2;%% Decodes data as required by [^http`:`/`/www`.w3`.org`/TR`/html401`/interact`/forms`.html`#h`-17`.13`.4`.1^ M
|
||||
IME type application/x`-www`-form`-urlencoded] (see UrlEncode).&]
|
||||
[s5;:Upp`:`:UrlDecode`(const char`*`,const char`*`,bool`): String
|
||||
[* UrlDecode]([@(0.0.255) const] [@(0.0.255) char] [@(0.0.255) `*][*@3 b],
|
||||
[@(0.0.255) const] [@(0.0.255) char] [@(0.0.255) `*][*@3 e], [@(0.0.255) bool]
|
||||
[*@3 plus`_is`_space] [@(0.0.255) `=] [@(0.0.255) true])&]
|
||||
[s5;:Upp`:`:UrlDecode`(const char`*`,int`,bool`): String [* UrlDecode]([@(0.0.255) const]
|
||||
[@(0.0.255) char] [@(0.0.255) `*][*@3 s], [@(0.0.255) int] [*@3 len], [@(0.0.255) bool]
|
||||
[*@3 plus`_is`_space] [@(0.0.255) `=] [@(0.0.255) true])&]
|
||||
[s5;:Upp`:`:UrlDecode`(const String`&`,bool`): String [* UrlDecode]([@(0.0.255) const]
|
||||
String[@(0.0.255) `&] [*@3 s], [@(0.0.255) bool] [*@3 plus`_is`_space]
|
||||
[@(0.0.255) `=] [@(0.0.255) true])&]
|
||||
[s2; [%% Decodes data as required by ][%%^http`:`/`/www`.w3`.org`/TR`/html401`/interact`/forms`.html`#h`-17`.13`.4`.1^ M
|
||||
IME type application/x`-www`-form`-urlencoded][%% (see UrlEncode).
|
||||
If ][*@3 plus`_is`_space] is false, `'`+`' is not converted to
|
||||
space.&]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:QPEncode`(const char`*`): [_^String^ String]_[* QPEncode]([@(0.0.255) const]_[@(0.0.255) c
|
||||
|
|
|
|||
|
|
@ -366,9 +366,9 @@ Vector<String> GetClipFiles(const String& data)
|
|||
{
|
||||
Vector<String> r;
|
||||
Vector<String> f = Split(data, '\n');
|
||||
for(int i = 0; i < f.GetCount(); i++)
|
||||
if(f[i].StartsWith("file://"))
|
||||
r.Add(f[i].Mid(7));
|
||||
for(String s : f)
|
||||
if(s.TrimStart("file://"))
|
||||
r << UrlDecode(s, false);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
|
@ -384,8 +384,8 @@ void AppendFiles(VectorMap<String, ClipData>& data, const Vector<String>& files)
|
|||
if(files.GetCount() == 0)
|
||||
return;
|
||||
String h;
|
||||
for(int i = 0; i < files.GetCount(); i++)
|
||||
h << "file://" << files[i] << '\n';
|
||||
for(String f : files)
|
||||
h << "file://" << UrlEncode(f) << '\n';
|
||||
data.GetAdd("files") = h;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue