Skip to content
This repository has been archived by the owner on Apr 21, 2023. It is now read-only.

Commit

Permalink
Move InstawebHandler initialization after validity checks.
Browse files Browse the repository at this point in the history
Creating an instaweb handler will run MakeRequestUrl, which assumes that
request->unparsed_uri is non-null.  So move the creation to after where
we check that it's non-null.  To be safe, move it all the way down to
where it's first needed, in case some other validity checks end up being
relevant.

Fixes #1248
  • Loading branch information
jeffkaufman committed Jan 21, 2016
1 parent 07bd70c commit e1fb66e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pagespeed/apache/mod_instaweb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -378,9 +378,6 @@ InstawebContext* build_context_for_request(request_rec* request) {
return NULL;
}

InstawebHandler instaweb_handler(request);
const RewriteOptions* options = instaweb_handler.options();

if (request->unparsed_uri == NULL) {
// TODO(jmarantz): consider adding Debug message if unparsed_uri is NULL,
// possibly of request->the_request which was non-null in the case where
Expand Down Expand Up @@ -445,6 +442,9 @@ InstawebContext* build_context_for_request(request_rec* request) {
return NULL;
}

InstawebHandler instaweb_handler(request);
const RewriteOptions* options = instaweb_handler.options();

const GoogleUrl& stripped_gurl = instaweb_handler.stripped_gurl();
if (!stripped_gurl.IsWebValid()) {
ap_log_rerror(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, request,
Expand Down
5 changes: 5 additions & 0 deletions pagespeed/system/system_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2287,3 +2287,8 @@ start_test AddResourceHeaders works for pagespeed resources.
URL="$TEST_ROOT/compressed/hello_js.custom_ext.pagespeed.ce.HdziXmtLIV.txt"
HTML_HEADERS=$($WGET_DUMP $URL)
check_from "$HTML_HEADERS" grep -q "^X-Foo: Bar"

start_test long url handling
# This is an extremely long url, enough that it should give a 4xx server error.
OUT=$($CURL -sS -D- "$TEST_ROOT/$(head -c 10000 < /dev/zero | tr '\0' 'a')")
check_from "$OUT" grep -q "414 Request-URI Too Large"

0 comments on commit e1fb66e

Please sign in to comment.