Changeset 146908 in webkit


Ignore:
Timestamp:
Mar 26, 2013 10:59:49 AM (11 years ago)
Author:
Christophe Dumez
Message:

Code duplication between HTTPParsers and HTTPValidation
https://bugs.webkit.org/show_bug.cgi?id=113283

Reviewed by Alexey Proskuryakov.

Source/WebCore:

Merged isValidHTTPToken() from HTTPValidation.h and isRFC2616Token() from
HTTPParsers.h. They were doing exactly the same thing and their
implementation was almost the same.

Removed HTTPValidation.* and moved remaining code to HTTPParsers.* as this
seems like the proper place and it seems odd to keep HTTPValidation for
just one function.

No new tests, no behavior change for layout tests.

  • CMakeLists.txt:
  • GNUmakefile.list.am:
  • Target.pri:
  • WebCore.gypi:
  • WebCore.vcproj/WebCore.vcproj:
  • WebCore.vcxproj/WebCore.vcxproj:
  • WebCore.vcxproj/WebCore.vcxproj.filters:
  • WebCore.xcodeproj/project.pbxproj:
  • platform/network/HTTPParsers.cpp:

(WebCore::isValidHTTPHeaderValue):
(WebCore):
(WebCore::isValidHTTPToken): Implementation is slightly simplified based on

isValidHTTPToken() from HTTPValidation.cpp. (c >= 0x80 replaced by (c >= 0x7F). (c <= 0x1F
c == 0x7F) is
c == ' ' c == '\t') is replaced

by (c <= 0x20). Those expressions are shorter but equivalent.
(WebCore::contentDispositionType):

  • platform/network/HTTPParsers.h:
  • platform/network/HTTPValidation.cpp: Removed.
  • platform/network/HTTPValidation.h: Removed.
  • xml/XMLHttpRequest.cpp: Stop including HTTPValidation.h.

Source/WebKit/chromium:

  • src/AssociatedURLLoader.cpp: Include HTTPParsers.h instead

of HTTPValidation.h to use isValidHTTPToken().

Location:
trunk/Source
Files:
2 deleted
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/CMakeLists.txt

    r146833 r146908  
    20752075    platform/network/HTTPParsers.cpp
    20762076    platform/network/HTTPRequest.cpp
    2077     platform/network/HTTPValidation.cpp
    20782077    platform/network/MIMEHeader.cpp
    20792078    platform/network/NetworkStateNotifier.cpp
  • trunk/Source/WebCore/ChangeLog

    r146907 r146908  
     12013-03-26  Christophe Dumez  <ch.dumez@sisa.samsung.com>
     2
     3        Code duplication between HTTPParsers and HTTPValidation
     4        https://bugs.webkit.org/show_bug.cgi?id=113283
     5
     6        Reviewed by Alexey Proskuryakov.
     7
     8        Merged isValidHTTPToken() from HTTPValidation.h and isRFC2616Token() from
     9        HTTPParsers.h. They were doing exactly the same thing and their
     10        implementation was almost the same.
     11
     12        Removed HTTPValidation.* and moved remaining code to HTTPParsers.* as this
     13        seems like the proper place and it seems odd to keep HTTPValidation for
     14        just one function.
     15
     16        No new tests, no behavior change for layout tests.
     17
     18        * CMakeLists.txt:
     19        * GNUmakefile.list.am:
     20        * Target.pri:
     21        * WebCore.gypi:
     22        * WebCore.vcproj/WebCore.vcproj:
     23        * WebCore.vcxproj/WebCore.vcxproj:
     24        * WebCore.vcxproj/WebCore.vcxproj.filters:
     25        * WebCore.xcodeproj/project.pbxproj:
     26        * platform/network/HTTPParsers.cpp:
     27        (WebCore::isValidHTTPHeaderValue):
     28        (WebCore):
     29        (WebCore::isValidHTTPToken): Implementation is slightly simplified based on
     30        isValidHTTPToken() from HTTPValidation.cpp. (c >= 0x80 || c == 0x7F) is
     31        replaced by (c >= 0x7F). (c <= 0x1F ||  c == ' ' || c == '\t') is replaced
     32        by (c <= 0x20). Those expressions are shorter but equivalent.
     33        (WebCore::contentDispositionType):
     34        * platform/network/HTTPParsers.h:
     35        * platform/network/HTTPValidation.cpp: Removed.
     36        * platform/network/HTTPValidation.h: Removed.
     37        * xml/XMLHttpRequest.cpp: Stop including HTTPValidation.h.
     38
    1392013-03-26  Sergio Villar Senin  <svillar@igalia.com>
    240
  • trunk/Source/WebCore/GNUmakefile.list.am

    r146855 r146908  
    59145914        Source/WebCore/platform/network/HTTPRequest.cpp \
    59155915        Source/WebCore/platform/network/HTTPRequest.h \
    5916         Source/WebCore/platform/network/HTTPValidation.cpp \
    5917         Source/WebCore/platform/network/HTTPValidation.h \
    59185916        Source/WebCore/platform/network/MIMEHeader.cpp \
    59195917        Source/WebCore/platform/network/MIMEHeader.h \
  • trunk/Source/WebCore/Target.pri

    r146833 r146908  
    11021102    platform/network/HTTPParsers.cpp \
    11031103    platform/network/HTTPRequest.cpp \
    1104     platform/network/HTTPValidation.cpp \
    11051104    platform/network/MIMEHeader.cpp \
    11061105    platform/network/NetworkStateNotifier.cpp \
     
    23642363    platform/network/HTTPParsers.h \
    23652364    platform/network/HTTPRequest.h \
    2366     platform/network/HTTPValidation.h \
    23672365    platform/network/HTTPStatusCodes.h \
    23682366    platform/network/MIMESniffing.h \
  • trunk/Source/WebCore/WebCore.gypi

    r146874 r146908  
    43714371            'platform/network/HTTPRequest.cpp',
    43724372            'platform/network/HTTPRequest.h',
    4373             'platform/network/HTTPValidation.cpp',
    4374             'platform/network/HTTPValidation.h',
    43754373            'platform/network/MIMEHeader.cpp',
    43764374            'platform/network/NetworkStateNotifier.cpp',
  • trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj

    r146833 r146908  
    3310333103                                </File>
    3310433104                                <File
    33105                                         RelativePath="..\platform\network\HTTPValidation.cpp"
    33106                                         >
    33107                                 </File>
    33108                                 <File
    33109                                         RelativePath="..\platform\network\HTTPValidation.h"
    33110                                         >
    33111                                 </File>
    33112                                 <File
    3311333105                                        RelativePath="..\platform\network\MIMEHeader.cpp"
    3311433106                                        >
  • trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj

    r146833 r146908  
    46314631    <ClCompile Include="..\platform\network\HTTPParsers.cpp" />
    46324632    <ClCompile Include="..\platform\network\HTTPRequest.cpp" />
    4633     <ClCompile Include="..\platform\network\HTTPValidation.cpp" />
    46344633    <ClCompile Include="..\platform\network\MIMEHeader.cpp" />
    46354634    <ClCompile Include="..\platform\network\NetworkStateNotifier.cpp" />
     
    1191111910    <ClInclude Include="..\platform\network\HTTPParsers.h" />
    1191211911    <ClInclude Include="..\platform\network\HTTPRequest.h" />
    11913     <ClInclude Include="..\platform\network\HTTPValidation.h" />
    1191411912    <ClInclude Include="..\platform\network\MIMEHeader.h" />
    1191511913    <ClInclude Include="..\platform\network\NetworkingContext.h" />
  • trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters

    r146833 r146908  
    32773277      <Filter>platform\network</Filter>
    32783278    </ClCompile>
    3279     <ClCompile Include="..\platform\network\HTTPValidation.cpp">
    3280       <Filter>platform\network</Filter>
    3281     </ClCompile>
    32823279    <ClCompile Include="..\platform\network\MIMEHeader.cpp">
    32833280      <Filter>platform\network</Filter>
     
    1008210079    </ClInclude>
    1008310080    <ClInclude Include="..\platform\network\HTTPRequest.h">
    10084       <Filter>platform\network</Filter>
    10085     </ClInclude>
    10086     <ClInclude Include="..\platform\network\HTTPValidation.h">
    1008710081      <Filter>platform\network</Filter>
    1008810082    </ClInclude>
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r146833 r146908  
    38093809                9A9CEF8D163B3EA100DE7EFE /* ExclusionShapeOutsideInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A9CEF8B163B3EA100DE7EFE /* ExclusionShapeOutsideInfo.cpp */; };
    38103810                9A9CEF8E163B3EA100DE7EFE /* ExclusionShapeOutsideInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A9CEF8C163B3EA100DE7EFE /* ExclusionShapeOutsideInfo.h */; settings = {ATTRIBUTES = (Private, ); }; };
    3811                 9B0FB191140DB5790022588F /* HTTPValidation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9B0FB18F140DB5790022588F /* HTTPValidation.cpp */; };
    3812                 9B0FB192140DB5790022588F /* HTTPValidation.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B0FB190140DB5790022588F /* HTTPValidation.h */; };
    38133811                9B1AB07C1648C7C40051F3F2 /* JSHTMLFormControlsCollectionCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9B1AB07B1648C7C40051F3F2 /* JSHTMLFormControlsCollectionCustom.cpp */; };
    38143812                9B24DE8E15194B9500C59C27 /* HTMLBDIElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B24DE8C15194B9500C59C27 /* HTMLBDIElement.h */; };
     
    1136511363                9A9CEF8B163B3EA100DE7EFE /* ExclusionShapeOutsideInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ExclusionShapeOutsideInfo.cpp; sourceTree = "<group>"; };
    1136611364                9A9CEF8C163B3EA100DE7EFE /* ExclusionShapeOutsideInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ExclusionShapeOutsideInfo.h; sourceTree = "<group>"; };
    11367                 9B0FB18F140DB5790022588F /* HTTPValidation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTTPValidation.cpp; sourceTree = "<group>"; };
    11368                 9B0FB190140DB5790022588F /* HTTPValidation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTTPValidation.h; sourceTree = "<group>"; };
    1136911365                9B1AB0791648C69D0051F3F2 /* HTMLFormControlsCollection.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = HTMLFormControlsCollection.idl; sourceTree = "<group>"; };
    1137011366                9B1AB07B1648C7C40051F3F2 /* JSHTMLFormControlsCollectionCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLFormControlsCollectionCustom.cpp; sourceTree = "<group>"; };
     
    1629716293                                A5D214AE12E905510090F370 /* HTTPRequest.cpp */,
    1629816294                                A5D214AF12E905510090F370 /* HTTPRequest.h */,
    16299                                 9B0FB18F140DB5790022588F /* HTTPValidation.cpp */,
    16300                                 9B0FB190140DB5790022588F /* HTTPValidation.h */,
    1630116295                                37DDCD9213844FD50008B793 /* MIMEHeader.cpp */,
    1630216296                                37DDCD9313844FD50008B793 /* MIMEHeader.h */,
     
    2482624820                                514C76730CE923A1007EF3CD /* HTTPParsers.h in Headers */,
    2482724821                                A5D214B212E905510090F370 /* HTTPRequest.h in Headers */,
    24828                                 9B0FB192140DB5790022588F /* HTTPValidation.h in Headers */,
    2482924822                                375CD232119D43C800A2A859 /* Hyphenation.h in Headers */,
    2483024823                                B275356E0B053814002CE64F /* Icon.h in Headers */,
     
    2816028153                                514C76720CE923A1007EF3CD /* HTTPParsers.cpp in Sources */,
    2816128154                                A5D214B112E905510090F370 /* HTTPRequest.cpp in Sources */,
    28162                                 9B0FB191140DB5790022588F /* HTTPValidation.cpp in Sources */,
    2816328155                                371A67CB11C6C7DB00047B8B /* HyphenationCF.cpp in Sources */,
    2816428156                                375CD23B119D44EA00A2A859 /* HyphenationMac.mm in Sources */,
  • trunk/Source/WebCore/platform/network/HTTPParsers.cpp

    r143880 r146908  
    103103}
    104104
     105bool isValidHTTPHeaderValue(const String& name)
     106{
     107    // FIXME: This should really match name against
     108    // field-value in section 4.2 of RFC 2616.
     109
     110    return !name.contains('\r') && !name.contains('\n');
     111}
     112
    105113// See RFC 2616, Section 2.2.
    106 bool isRFC2616Token(const String& characters)
     114bool isValidHTTPToken(const String& characters)
    107115{
    108116    if (characters.isEmpty())
     
    110118    for (unsigned i = 0; i < characters.length(); ++i) {
    111119        UChar c = characters[i];
    112         if (c >= 0x80 || c <= 0x1F || c == 0x7F
     120        if (c <= 0x20 || c >= 0x7F
    113121            || c == '(' || c == ')' || c == '<' || c == '>' || c == '@'
    114122            || c == ',' || c == ';' || c == ':' || c == '\\' || c == '"'
    115123            || c == '/' || c == '[' || c == ']' || c == '?' || c == '='
    116             || c == '{' || c == '}' || c == ' ' || c == '\t')
     124            || c == '{' || c == '}')
    117125        return false;
    118126    }
     
    150158    //
    151159    // without a disposition token... screen those out.
    152     if (!isRFC2616Token(dispositionType))
     160    if (!isValidHTTPToken(dispositionType))
    153161        return ContentDispositionNone;
    154162
  • trunk/Source/WebCore/platform/network/HTTPParsers.h

    r143880 r146908  
    5656
    5757ContentDispositionType contentDispositionType(const String&);
    58 bool isRFC2616Token(const String&);
     58bool isValidHTTPHeaderValue(const String&);
     59bool isValidHTTPToken(const String&);
    5960bool parseHTTPRefresh(const String& refresh, bool fromHttpEquivMeta, double& delay, String& url);
    6061double parseDate(const String&);
  • trunk/Source/WebCore/xml/XMLHttpRequest.cpp

    r146537 r146908  
    3939#include "HTMLDocument.h"
    4040#include "HTTPParsers.h"
    41 #include "HTTPValidation.h"
    4241#include "HistogramSupport.h"
    4342#include "InspectorInstrumentation.h"
  • trunk/Source/WebKit/chromium/ChangeLog

    r146894 r146908  
     12013-03-26  Christophe Dumez  <ch.dumez@sisa.samsung.com>
     2
     3        Code duplication between HTTPParsers and HTTPValidation
     4        https://bugs.webkit.org/show_bug.cgi?id=113283
     5
     6        Reviewed by Alexey Proskuryakov.
     7
     8        * src/AssociatedURLLoader.cpp: Include HTTPParsers.h instead
     9        of HTTPValidation.h to use isValidHTTPToken().
     10
    1112013-03-26  Yufeng Shen  <miletus@chromium.org>
    212
  • trunk/Source/WebKit/chromium/src/AssociatedURLLoader.cpp

    r144568 r146908  
    3535#include "DocumentThreadableLoader.h"
    3636#include "DocumentThreadableLoaderClient.h"
    37 #include "HTTPValidation.h"
     37#include "HTTPParsers.h"
    3838#include "ResourceError.h"
    3939#include "SubresourceLoader.h"
Note: See TracChangeset for help on using the changeset viewer.