From 0866f49f4e2ac6f0400502f5e6ca9a13dd8c7db9 Mon Sep 17 00:00:00 2001 From: volzhs Date: Fri, 30 Sep 2016 03:11:45 +0900 Subject: Fix error when using 2 or more slashes on resource path --- core/ustring.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'core/ustring.cpp') diff --git a/core/ustring.cpp b/core/ustring.cpp index 0d887210c3..a749ce31fc 100644 --- a/core/ustring.cpp +++ b/core/ustring.cpp @@ -3073,6 +3073,11 @@ String String::simplify_path() const { } s =s.replace("\\","/"); + while(true){ // in case of using 2 or more slash + String compare = s.replace("//","/"); + if (s==compare) break; + else s=compare; + } Vector dirs = s.split("/",false); for(int i=0;i Date: Fri, 30 Sep 2016 03:28:05 +0900 Subject: Fix typo for word_wrap --- core/ustring.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'core/ustring.cpp') diff --git a/core/ustring.cpp b/core/ustring.cpp index 0d887210c3..f7dcba6b14 100644 --- a/core/ustring.cpp +++ b/core/ustring.cpp @@ -3173,7 +3173,7 @@ bool String::is_valid_identifier() const { //kind of poor should be rewritten properly -String String::world_wrap(int p_chars_per_line) const { +String String::word_wrap(int p_chars_per_line) const { int from=0; int last_space=0; -- cgit v1.2.3 From a3131a6b5bf5357e5c70ba6fea4a0963f4b341b4 Mon Sep 17 00:00:00 2001 From: Ariel Manzur Date: Thu, 20 Oct 2016 09:58:00 -0300 Subject: added implementation of is_valid_ip_address() --- core/ustring.cpp | 90 ++++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 71 insertions(+), 19 deletions(-) (limited to 'core/ustring.cpp') diff --git a/core/ustring.cpp b/core/ustring.cpp index 2e907381f7..f9c10615b3 100644 --- a/core/ustring.cpp +++ b/core/ustring.cpp @@ -1543,11 +1543,11 @@ String::String(const StrRange& p_range) { copy_from(p_range.c_str,p_range.len); } -int String::hex_to_int() const { +int String::hex_to_int(bool p_with_prefix) const { int l = length(); - if (l<3) - return 0; + if (p_with_prefix && l<3) + return 0; const CharType *s=ptr(); @@ -1556,15 +1556,16 @@ int String::hex_to_int() const { if (sign<0) { s++; l--; - if (l<2) + if (p_with_prefix && l<2) return 0; } - if (s[0]!='0' || s[1]!='x') - return 0; - - s+=2; - l-=2; + if (p_with_prefix) { + if (s[0]!='0' || s[1]!='x') + return 0; + s+=2; + l-=2; + }; int hex=0; @@ -3510,6 +3511,36 @@ bool String::is_valid_integer() const { } +bool String::is_valid_hex_number(bool p_with_prefix) const { + + int from = 0; + int len = length(); + + if (len!=1 && (operator[](0)=='+' || operator[](0)=='-')) + from++; + + if (p_with_prefix) { + + if (len < 2) + return false; + if (operator[](from) != '0' || operator[](from+1) != 'x') { + return false; + }; + from += 2; + }; + + for (int i=from; i= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F')) + continue; + return false; + }; + + return true; +}; + + bool String::is_valid_float() const { int len = length(); @@ -3646,20 +3677,41 @@ bool String::is_valid_html_color() const { } + bool String::is_valid_ip_address() const { - Vector ip = split("."); - if (ip.size()!=4) - return false; - for(int i=0;i= 0) { - String n = ip[i]; - if (!n.is_valid_integer()) - return false; - int val = n.to_int(); - if (val<0 || val>255) + Vector ip = split(":"); + for (int i=0; i 0xffff) + return false; + continue; + }; + if (!n.is_valid_ip_address()) + return false; + }; + + } else { + Vector ip = split("."); + if (ip.size()!=4) return false; - } + for(int i=0;i255) + return false; + } + }; return true; } -- cgit v1.2.3