Overview
Comment: | OFURL: Store the URL-encoded version internally
This allows retrieving it how it was originally stored, which is useful |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
a15b403a1148499b88fb8366809afed2 |
User & Date: | js on 2017-11-06 23:01:57 |
Other Links: | manifest | tags |
Context
2017-11-11
| ||
22:28 | Make the default OFFileManager a singleton check-in: 9a60a5adfc user: js tags: trunk | |
2017-11-06
| ||
23:01 | OFURL: Store the URL-encoded version internally check-in: a15b403a11 user: js tags: trunk | |
00:10 | of_string_utf8_encode(): Remove a variable check-in: 455caa7063 user: js tags: trunk | |
Changes
Modified src/OFHTTPServer.m from [380d4e5179] to [3bc806eac7].
︙ | |||
661 662 663 664 665 666 667 | 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 | - - + + - + | if ((pos = [_path rangeOfString: @"?"].location) != OF_NOT_FOUND) { OFString *path, *query; path = [_path substringWithRange: of_range(0, pos)]; query = [_path substringWithRange: of_range(pos + 1, [_path length] - pos - 1)]; |
︙ |
Modified src/OFMutableURL.h from [716b3b017c] to [cd0e75d21f].
︙ | |||
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | */ @interface OFMutableURL: OFURL /*! * The scheme part of the URL. */ @property OF_NULLABLE_PROPERTY (readwrite, copy, nonatomic) OFString *scheme; /*! * The scheme part of the URL in URL-encoded form. * * Setting this retains the original URL-encoding used - if more characters * than necessary are URL-encoded, it is kept this way. */ @property OF_NULLABLE_PROPERTY (readwrite, copy, nonatomic) OFString *URLEncodedScheme; /*! * The host part of the URL. */ @property OF_NULLABLE_PROPERTY (readwrite, copy, nonatomic) OFString *host; /*! * The host part of the URL in URL-encoded form. * * Setting this retains the original URL-encoding used - if more characters * than necessary are URL-encoded, it is kept this way. */ @property OF_NULLABLE_PROPERTY (readwrite, copy, nonatomic) OFString *URLEncodedHost; /*! * The port part of the URL. */ @property OF_NULLABLE_PROPERTY (readwrite, copy, nonatomic) OFNumber *port; /*! * The user part of the URL. */ @property OF_NULLABLE_PROPERTY (readwrite, copy, nonatomic) OFString *user; /*! * The user part of the URL in URL-encoded form. * * Setting this retains the original URL-encoding used - if more characters * than necessary are URL-encoded, it is kept this way. */ @property OF_NULLABLE_PROPERTY (readwrite, copy, nonatomic) OFString *URLEncodedUser; /*! * The password part of the URL. */ @property OF_NULLABLE_PROPERTY (readwrite, copy, nonatomic) OFString *password; /*! * The password part of the URL in URL-encoded form. * * Setting this retains the original URL-encoding used - if more characters * than necessary are URL-encoded, it is kept this way. */ @property OF_NULLABLE_PROPERTY (readwrite, copy, nonatomic) OFString *URLEncodedPassword; /*! * The path part of the URL. */ @property OF_NULLABLE_PROPERTY (readwrite, copy, nonatomic) OFString *path; /*! * The path part of the URL in URL-encoded form. * * Setting this retains the original URL-encoding used - if more characters * than necessary are URL-encoded, it is kept this way. */ @property OF_NULLABLE_PROPERTY (readwrite, copy, nonatomic) OFString *URLEncodedPath; /*! * The path of the URL split into components. * * The first component must always be empty to designate the root. */ @property OF_NULLABLE_PROPERTY (readwrite, copy, nonatomic) OFArray OF_GENERIC(OFString *) *pathComponents; /*! * The query part of the URL. */ @property OF_NULLABLE_PROPERTY (readwrite, copy, nonatomic) OFString *query; /*! * The query part of the URL in URL-encoded form. * * Setting this retains the original URL-encoding used - if more characters * than necessary are URL-encoded, it is kept this way. */ @property OF_NULLABLE_PROPERTY (readwrite, copy, nonatomic) OFString *URLEncodedQuery; /*! * The fragment part of the URL. */ @property OF_NULLABLE_PROPERTY (readwrite, copy, nonatomic) OFString *fragment; /*! * The fragment part of the URL in URL-encoded form. * * Setting this retains the original URL-encoding used - if more characters * than necessary are URL-encoded, it is kept this way. */ @property OF_NULLABLE_PROPERTY (readwrite, copy, nonatomic) OFString *URLEncodedFragment; /*! * @brief Creates a new mutable URL. * * @return A new, autoreleased OFMutableURL */ + (instancetype)URL; |
︙ |
Modified src/OFMutableURL.m from [f6b587c9bc] to [b9f96c6e08].
︙ | |||
21 22 23 24 25 26 27 | 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | - - + + + + + + + + + + + + + + - - + + + + + + + + + + + + - - + + + + + + + + + + + + - - + + + + + + + + + + + + + - - + + + + + + + + + + + + - - + + | #import "OFNumber.h" #import "OFString.h" #import "OFURL+Private.h" #import "OFInvalidFormatException.h" @implementation OFMutableURL |
︙ | |||
98 99 100 101 102 103 104 | 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 | + + + + + + + + + + + - - + + + + + + + + + + + + + - - + + | [self setPath: [components componentsJoinedByString: @"/"]]; objc_autoreleasePoolPop(pool); } - (void)setQuery: (OFString *)query { void *pool = objc_autoreleasePoolPush(); [self setURLEncodedQuery: [query stringByURLEncodingWithAllowedCharacters: [OFCharacterSet URLQueryAllowedCharacterSet]]]; objc_autoreleasePoolPop(pool); } - (void)setURLEncodedQuery: (OFString *)URLEncodedQuery { |
︙ |
Modified src/OFURL.h from [7ad59d1622] to [8793c73a5f].
︙ | |||
27 28 29 30 31 32 33 | 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | - + - - + + + | /*! * @class OFURL OFURL.h ObjFW/OFURL.h * * @brief A class for parsing URLs and accessing parts of it. */ @interface OFURL: OFObject <OFCopying, OFMutableCopying, OFSerialization> { |
︙ |
Modified src/OFURL.m from [09db0decaa] to [674edf5266].
︙ | |||
344 345 346 347 348 349 350 | 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 | + - - + + - - - - - + + + + - - + + - + - + - - - - + - + - - - + + - - + + + - + - | if (strncmp(tmp, "://", 3) != 0) @throw [OFInvalidFormatException exception]; for (tmp2 = UTF8String; tmp2 < tmp; tmp2++) *tmp2 = of_ascii_tolower(*tmp2); _URLEncodedScheme = [[OFString alloc] |
︙ | |||
447 448 449 450 451 452 453 | 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 | - - + + - - + + + - + - + - + - + - + - - + - - - + + + - + - - + + - + | self = [super init]; @try { void *pool = objc_autoreleasePoolPush(); char *tmp; |
︙ | |||
576 577 578 579 580 581 582 | 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 | - - + + - - - - - + + + + + + - + + - + + - + + - + + - + + - + + - + - - + + - - - - - + + + + + - + - + - - + - + - - + - + - - + - - + - + - + - - + - - + + - + + + - - + + + + + - + - - | } return self; } - (void)dealloc { |
︙ | |||
744 745 746 747 748 749 750 | 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 | - + - + - - + - - + - - + + - - - - - + + + + + - - + - + - + - - - + + - - + + - - + + - + - - + + - - + + - - - + - + - + | objc_autoreleasePoolPop(pool); return [ret autorelease]; } - (OFString *)query { |
︙ |
Modified tests/OFURLTests.m from [96f3992920] to [291a443212].
︙ | |||
26 27 28 29 30 31 32 | 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | - + + - + | #import "OFAutoreleasePool.h" #import "OFInvalidFormatException.h" #import "TestsAppDelegate.h" static OFString *module = @"OFURL"; |
︙ | |||
107 108 109 110 111 112 113 114 115 116 | 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | [[OFURL URLWithString: @"HTTP://bar/"] isEqual: u3]) TEST(@"-[hash:]", [u1 hash] == [u4 hash] && [u2 hash] != [u3 hash]) EXPECT_EXCEPTION(@"Detection of invalid format", OFInvalidFormatException, [OFURL URLWithString: @"http"]) mu = [OFMutableURL URL]; TEST(@"-[setScheme:]", R([mu setScheme: @"ht:tp"]) && [[mu URLEncodedScheme] isEqual: @"ht%3Atp"]) TEST(@"-[setHost:]", R([mu setHost: @"ho:st"]) && [[mu URLEncodedHost] isEqual: @"ho%3Ast"]) TEST(@"-[setUser:]", R([mu setUser: @"us:er"]) && [[mu URLEncodedUser] isEqual: @"us%3Aer"]) TEST(@"-[setPassword:]", R([mu setPassword: @"pass:word"]) && [[mu URLEncodedPassword] isEqual: @"pass%3Aword"]) TEST(@"-[setPath:]", R([mu setPath: @"pa/th@?"]) && [[mu URLEncodedPath] isEqual: @"pa/th@%3F"]) TEST(@"-[setQuery:]", R([mu setQuery: @"que/ry?#"]) && [[mu URLEncodedQuery] isEqual: @"que/ry?%23"]) TEST(@"-[setFragment:]", R([mu setFragment: @"frag/ment?#"]) && [[mu URLEncodedFragment] isEqual: @"frag/ment?%23"]) [pool drain]; } @end |