decodes path like "file%20name" to "file name"
| 4006 | |
| 4007 | /// decodes path like "file%20name" to "file name" |
| 4008 | lString16 DecodeHTMLUrlString( lString16 s ) |
| 4009 | { |
| 4010 | const lChar16 * str = s.c_str(); |
| 4011 | for ( int i=0; str[i]; i++ ) { |
| 4012 | if ( str[i]=='%' ) { |
| 4013 | int ch = decodeHTMLChar( str + i ); |
| 4014 | if ( ch==0 ) { |
| 4015 | continue; |
| 4016 | } |
| 4017 | // HTML encoded char found |
| 4018 | lString16 res; |
| 4019 | res.reserve(s.length()); |
| 4020 | res.append(str, i); |
| 4021 | res.append(1, ch); |
| 4022 | i+=3; |
| 4023 | |
| 4024 | // continue conversion |
| 4025 | for ( ; str[i]; i++ ) { |
| 4026 | if ( str[i]=='%' ) { |
| 4027 | ch = decodeHTMLChar( str + i ); |
| 4028 | if ( ch==0 ) { |
| 4029 | res.append(1, str[i]); |
| 4030 | continue; |
| 4031 | } |
| 4032 | res.append(1, ch); |
| 4033 | i+=2; |
| 4034 | } else { |
| 4035 | res.append(1, str[i]); |
| 4036 | } |
| 4037 | } |
| 4038 | return res; |
| 4039 | } |
| 4040 | } |
| 4041 | return s; |
| 4042 | } |
| 4043 | |
| 4044 | void limitStringSize(lString16 & str, int maxSize) { |
| 4045 | if ((int) str.length() < maxSize) |
no test coverage detected