Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
dart::bin::UriDecoder Class Reference

#include <file.h>

Public Member Functions

 UriDecoder (const char *uri)
 
 ~UriDecoder ()
 
const char * decoded () const
 

Detailed Description

Definition at line 362 of file file.h.

Constructor & Destructor Documentation

◆ UriDecoder()

dart::bin::UriDecoder::UriDecoder ( const char *  uri)
explicit

Definition at line 1423 of file file.cc.

1423 : uri_(uri) {
1424 const char* ch = uri;
1425 while ((*ch != '\0') && (*ch != '%')) {
1426 ch++;
1427 }
1428 if (*ch == 0) {
1429 // if there are no '%', nothing to decode, refer to original as decoded.
1430 decoded_ = const_cast<char*>(uri);
1431 return;
1432 }
1433 const intptr_t len = strlen(uri);
1434 // Decoded string should be shorter than original because of
1435 // percent-encoding.
1436 char* dest = reinterpret_cast<char*>(malloc(len + 1));
1437 int i = ch - uri;
1438 // Copy all characters up to first '%' at index i.
1439 strncpy(dest, uri, i);
1440 decoded_ = dest;
1441 dest += i;
1442 while (*ch != '\0') {
1443 if (*ch != '%') {
1444 *(dest++) = *(ch++);
1445 continue;
1446 }
1447 if ((i + 3 > len) || !HexCharPairToByte(ch + 1, dest)) {
1448 free(decoded_);
1449 decoded_ = nullptr;
1450 return;
1451 }
1452 ++dest;
1453 ch += 3;
1454 }
1455 *dest = 0;
1456}
void * malloc(size_t size)
Definition: allocation.cc:19
dest
Definition: zip.py:79

◆ ~UriDecoder()

dart::bin::UriDecoder::~UriDecoder ( )

Definition at line 1458 of file file.cc.

1458 {
1459 if (uri_ != decoded_ && decoded_ != nullptr) {
1460 free(decoded_);
1461 }
1462}

Member Function Documentation

◆ decoded()

const char * dart::bin::UriDecoder::decoded ( ) const
inline

Definition at line 367 of file file.h.

367{ return decoded_; }

The documentation for this class was generated from the following files: