- Timestamp:
- Oct 6, 2015 1:16:06 PM (9 years ago)
- svn:sync-xref-src-repo-rev:
- 103104
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/misc/uri.cpp
r58049 r58050 765 765 && Parsed.cchPath) 766 766 { 767 const char *pszPathOff = &pszUri[Parsed.offPath]; 767 /* 768 * Calculate the size of the encoded result. 769 */ 768 770 size_t cbResult = 0; 769 771 770 772 /* Skip the leading slash if a DOS drive letter (e.g. "C:") is detected right after it. */ 771 773 if ( Parsed.cchPath >= 3 772 && psz PathOff[0] == '/' /* Leading slash. */773 && RT_C_IS_ALPHA(psz PathOff[1]) /* Drive letter. */774 && psz PathOff[2] == ':')774 && pszUri[Parsed.offPath] == '/' /* Leading slash. */ 775 && RT_C_IS_ALPHA(pszUri[Parsed.offPath + 1]) /* Drive letter. */ 776 && pszUri[Parsed.offPath + 2] == ':') 775 777 { 776 778 Parsed.offPath++; 777 779 Parsed.cchPath--; 778 pszPathOff++; 779 } 780 781 if (uFormat == URI_FILE_FORMAT_WIN) 782 { 783 /* Authority given? */ 784 if (Parsed.cchAuthority) 785 { 786 /* Include authority as part of UNC path. */ 787 cbResult += 2; /* UNC slashes "\\". */ 788 cbResult += Parsed.cchAuthority; 789 } 780 } 781 782 /* Windows: Authority given? Include authority as part of UNC path */ 783 if (uFormat == URI_FILE_FORMAT_WIN && Parsed.cchAuthority) 784 { 785 cbResult += 2; /* UNC slashes "\\". */ 786 cbResult += Parsed.cchAuthority; 790 787 } 791 788 … … 794 791 795 792 /* 796 * Compose string.793 * Compose encoded string. 797 794 */ 798 795 char *pszResult; … … 801 798 { 802 799 size_t cbTmp = cbResult; 803 if (uFormat == URI_FILE_FORMAT_WIN) 800 801 /* Windows: If an authority is given, add the required UNC prefix. */ 802 if (uFormat == URI_FILE_FORMAT_WIN && Parsed.cchAuthority) 804 803 { 805 /* If an authority is given, add the required UNC prefix. */ 806 if (Parsed.cchAuthority) 807 { 808 rc = RTStrCatP(&pszTmp, &cbTmp, "\\\\"); 809 if (RT_SUCCESS(rc)) 810 /** @todo r=bird: YOU MUST DECODE THE STRING!! */ 811 rc = RTStrCatPEx(&pszTmp, &cbTmp, &pszUri[Parsed.offAuthority], Parsed.cchAuthority); 812 } 804 rc = RTStrCatP(&pszTmp, &cbTmp, "\\\\"); 805 if (RT_SUCCESS(rc)) 806 rc = RTStrCatPEx(&pszTmp, &cbTmp, &pszUri[Parsed.offAuthority], Parsed.cchAuthority); 813 807 } 814 815 /** @todo r=bird: YOU MUST DECODE THE STRING!! */816 808 if (RT_SUCCESS(rc)) 817 809 rc = RTStrCatPEx(&pszTmp, &cbTmp, &pszUri[Parsed.offPath], Parsed.cchPath); 818 819 if (RT_FAILURE(rc)) 820 RTStrFree(pszResult); 821 } 822 else 823 rc = VERR_NO_MEMORY; 824 if (RT_SUCCESS(rc)) 825 { 826 AssertPtr(pszResult); 827 Assert(cbResult); 828 char *pszPath = rtUriPercentDecodeN(pszResult, cbResult - 1 /* Minus termination */); 810 AssertRC(rc); /* Shall not happen! */ 811 if (RT_SUCCESS(rc)) 812 { 813 /* 814 * Decode the string and switch the slashes around the request way before returning. 815 */ 816 char *pszPath = rtUriPercentDecodeN(pszResult, cbResult - 1 /* Minus termination */); 817 if (pszPath) 818 { 819 RTStrFree(pszResult); 820 821 if (uFormat == URI_FILE_FORMAT_UNIX) 822 return RTPathChangeToUnixSlashes(pszPath, true); 823 Assert(uFormat == URI_FILE_FORMAT_WIN); 824 return RTPathChangeToDosSlashes(pszPath, true); 825 } 826 827 /* Failed. */ 828 } 829 829 RTStrFree(pszResult); 830 if (uFormat == URI_FILE_FORMAT_UNIX) 831 return RTPathChangeToUnixSlashes(pszPath, true); 832 Assert(uFormat == URI_FILE_FORMAT_WIN); 833 return RTPathChangeToDosSlashes(pszPath, true); 834 } 835 } 836 830 } 831 } 837 832 return NULL; 838 833 }
Note:
See TracChangeset
for help on using the changeset viewer.