params += extraParams;
}
- params += '&' + vaadin.getBrowserDetailsParameters(appId);
+ params += '&' + vaadin.getBrowserDetailsParameters(appId, getConfig('sendUrlsAsParameters'));
var r;
try {
ws.pendingApps = null;
}
},
- getBrowserDetailsParameters: function(parentElementId) {
+ getBrowserDetailsParameters: function(parentElementId, sendUrlsAsParameters) {
// Screen height and width
var params = 'v-sh=' + window.screen.height;
params += '&v-sw=' + window.screen.width;
}
// Location
- params += '&v-loc=' + encodeURIComponent(location.href);
+ if (sendUrlsAsParameters !== false) {
+ params += '&v-loc=' + encodeURIComponent(location.href);
+ }
// Window name
if (window.name) {
appConfig.put(ApplicationConstants.SERVICE_URL, serviceUrl);
}
+ boolean sendUrlsAsParameters = vaadinService
+ .getDeploymentConfiguration().isSendUrlsAsParameters();
+ if (!sendUrlsAsParameters) {
+ appConfig.put("sendUrlsAsParameters", false);
+ }
+
return appConfig;
}
static final String SERVLET_PARAMETER_UI_PROVIDER = "UIProvider";
static final String SERVLET_PARAMETER_LEGACY_PROPERTY_TOSTRING = "legacyPropertyToString";
static final String SERVLET_PARAMETER_SYNC_ID_CHECK = "syncIdCheck";
+ static final String SERVLET_PARAMETER_SENDURLSASPARAMETERS = "sendUrlsAsParameters";
// Configurable parameter names
static final String PARAMETER_VAADIN_RESOURCES = "Resources";
*/
public static final boolean DEFAULT_SYNC_ID_CHECK = true;
+ public static final boolean DEFAULT_SEND_URLS_AS_PARAMETERS = true;
+
private final Properties initParameters;
private boolean productionMode;
private boolean xsrfProtectionEnabled;
private final Class<?> systemPropertyBaseClass;
private LegacyProperyToStringMode legacyPropertyToStringMode;
private boolean syncIdCheck;
+ private boolean sendUrlsAsParameters;
/**
* Create a new deployment configuration instance.
checkPushMode();
checkLegacyPropertyToString();
checkSyncIdCheck();
+ checkSendUrlsAsParameters();
}
private void checkLegacyPropertyToString() {
return syncIdCheck;
}
+ /**
+ * {@inheritDoc}
+ * <p>
+ * The default value is <code>true</code>.
+ */
+ @Override
+ public boolean isSendUrlsAsParameters() {
+ return sendUrlsAsParameters;
+ }
+
/**
* {@inheritDoc}
* <p>
Boolean.toString(DEFAULT_SYNC_ID_CHECK)).equals("true");
}
+ private void checkSendUrlsAsParameters() {
+ sendUrlsAsParameters = getApplicationOrSystemProperty(
+ Constants.SERVLET_PARAMETER_SENDURLSASPARAMETERS,
+ Boolean.toString(DEFAULT_SEND_URLS_AS_PARAMETERS)).equals(
+ "true");
+ }
+
private Logger getLogger() {
return Logger.getLogger(getClass().getName());
}
*/
public int getHeartbeatInterval();
+ /**
+ * Returns whether the sending of URL's as GET and POST parameters in
+ * requests with content-type <code>application/x-www-form-urlencoded</code>
+ * is enabled or not.
+ *
+ * @return <code>false</code> if set to false or <code>true</code> otherwise
+ */
+ public boolean isSendUrlsAsParameters();
+
/**
* Returns whether a session should be closed when all its open UIs have
* been idle for longer than its configured maximum inactivity time.
* @return The browser location URI.
*/
public URI getLocation() {
+ if (location == null
+ && !uI.getSession().getConfiguration().isSendUrlsAsParameters()) {
+ throw new IllegalStateException("Location is not available as the "
+ + Constants.SERVLET_PARAMETER_SENDURLSASPARAMETERS
+ + " parameter is configured as false");
+ }
return location;
}
return null;
}
+ @Override
+ public boolean isSendUrlsAsParameters() {
+ return DefaultDeploymentConfiguration.DEFAULT_SEND_URLS_AS_PARAMETERS;
+ }
+
}
}
private Map<String, String> applicationOrSystemProperty = new HashMap<String, String>();
private LegacyProperyToStringMode legacyPropertyToStringMode = LegacyProperyToStringMode.DISABLED;
private boolean syncIdCheckEnabled = true;
+ private boolean sendUrlsAsParameters = true;
@Override
public boolean isProductionMode() {
this.legacyPropertyToStringMode = legacyPropertyToStringMode;
}
+ @Override
+ public boolean isSendUrlsAsParameters() {
+ return sendUrlsAsParameters;
+ }
+
}
--- /dev/null
+/*
+ * Copyright 2000-2014 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.tests.applicationservlet;
+
+import com.vaadin.launcher.CustomDeploymentConfiguration;
+import com.vaadin.launcher.CustomDeploymentConfiguration.Conf;
+import com.vaadin.server.Constants;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUIWithLog;
+
+@CustomDeploymentConfiguration({ @Conf(name = Constants.SERVLET_PARAMETER_SENDURLSASPARAMETERS, value = "false") })
+public class DisableSendUrlAsParameters extends AbstractTestUIWithLog {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ try {
+ log("Init location: " + getPage().getLocation());
+ } catch (IllegalStateException e) {
+ log("Init location exception: " + e.getMessage());
+ }
+ }
+
+}
--- /dev/null
+/*
+ * Copyright 2000-2014 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.tests.applicationservlet;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.vaadin.tests.tb3.SingleBrowserTest;
+
+public class DisableSendUrlAsParametersTest extends SingleBrowserTest {
+
+ @Test
+ public void testInitLocation() {
+ openTestURL();
+
+ String logRow = getLogRow(0);
+
+ Assert.assertEquals(
+ "1. Init location exception: Location is not available as the sendUrlsAsParameters parameter is configured as false",
+ logRow);
+ }
+}
}
protected void warnIfWidgetsetMaybeNotCompiled() {
+ // Can't check location if sendUrlAsParameters is disabled
+ if (!getSession().getConfiguration().isSendUrlsAsParameters()) {
+ return;
+ }
+
// Ignore if using debug mode
String query = getPage().getLocation().getQuery();
if (query != null && query.matches(".*[&?]gwt\\.codesvr.*")) {