From: <rb...@us...> - 2017-08-07 18:17:48
|
Revision: 14772 http://sourceforge.net/p/htmlunit/code/14772 Author: rbri Date: 2017-08-07 18:17:45 +0000 (Mon, 07 Aug 2017) Log Message: ----------- no longer include the file path when uploading a file Issue 1908 Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/HttpWebConnection.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLInputElement.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlFileInput2Test.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlFileInputTest.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2017-08-07 07:34:47 UTC (rev 14771) +++ trunk/htmlunit/src/changes/changes.xml 2017-08-07 18:17:45 UTC (rev 14772) @@ -8,6 +8,12 @@ <body> <release version="2.28" date="???" description="Bugfixes, Chrome 60"> + <action type="fix" dev="rbri" issue="1908"> + There is an option for IE that enables/disables the sending of the + complete file path when uploading a file. Starting with this version + we simulate this in disabled state like the default setting for the + internet zone. + </action> <action type="fix" dev="rbri"> BrowserVersion.clone now copies the system-timezone attribute. </action> Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 2017-08-07 07:34:47 UTC (rev 14771) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 2017-08-07 18:17:45 UTC (rev 14772) @@ -291,10 +291,6 @@ /** */ @BrowserFeature(IE) - HEADER_CONTENT_DISPOSITION_ABSOLUTE_PATH, - - /** */ - @BrowserFeature(IE) HTMLABBREVIATED, /** HtmlAllCollection.item returns null instead of undefined if an element was not found. */ @@ -445,13 +441,9 @@ HTMLINPUT_FILE_SELECTION_START_END_NULL, /** HTMLInputElement: type {@code file} value to be {@code fakepath}. */ - @BrowserFeature(CHROME) + @BrowserFeature({CHROME, IE}) HTMLINPUT_FILE_VALUE_FAKEPATH, - /** HTMLInputElement: type {@code file} value to be only the file name. */ - @BrowserFeature(FF) - HTMLINPUT_FILE_VALUE_NO_PATH, - /** Should the HTMLElement of {@code keygen} have no end tag. */ @BrowserFeature(IE) HTMLKEYGEN_END_TAG_FORBIDDEN, Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/HttpWebConnection.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/HttpWebConnection.java 2017-08-07 07:34:47 UTC (rev 14771) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/HttpWebConnection.java 2017-08-07 18:17:45 UTC (rev 14772) @@ -14,7 +14,6 @@ */ package com.gargoylesoftware.htmlunit; -import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.HEADER_CONTENT_DISPOSITION_ABSOLUTE_PATH; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.URL_AUTH_CREDENTIALS; import java.io.ByteArrayInputStream; @@ -428,9 +427,6 @@ else if (pairWithFile.getFileName() != null) { filename = pairWithFile.getFileName(); } - else if (webClient_.getBrowserVersion().hasFeature(HEADER_CONTENT_DISPOSITION_ABSOLUTE_PATH)) { - filename = file.getAbsolutePath(); - } else { filename = file.getName(); } @@ -459,9 +455,6 @@ else if (pairWithFile.getFileName() != null) { filename = pairWithFile.getFileName(); } - else if (webClient_.getBrowserVersion().hasFeature(HEADER_CONTENT_DISPOSITION_ABSOLUTE_PATH)) { - filename = pairWithFile.getFile().getAbsolutePath(); - } else { filename = pairWithFile.getFile().getName(); } Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLInputElement.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLInputElement.java 2017-08-07 07:34:47 UTC (rev 14771) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLInputElement.java 2017-08-07 18:17:45 UTC (rev 14772) @@ -18,7 +18,6 @@ import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.HTMLINPUT_FILES_UNDEFINED; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.HTMLINPUT_FILE_SELECTION_START_END_NULL; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.HTMLINPUT_FILE_VALUE_FAKEPATH; -import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.HTMLINPUT_FILE_VALUE_NO_PATH; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_ALIGN_FOR_INPUT_IGNORES_VALUES; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_INPUT_NUMBER_SELECTION_START_END_NULL; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_INPUT_SET_TYPE_LOWERCASE; @@ -591,10 +590,7 @@ if (getBrowserVersion().hasFeature(HTMLINPUT_FILE_VALUE_FAKEPATH)) { return "C:\\fakepath\\" + name; } - else if (getBrowserVersion().hasFeature(HTMLINPUT_FILE_VALUE_NO_PATH)) { - return name; - } - return first.getAbsolutePath(); + return name; } return super.getValue(); } Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlFileInput2Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlFileInput2Test.java 2017-08-07 07:34:47 UTC (rev 14771) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlFileInput2Test.java 2017-08-07 18:17:45 UTC (rev 14772) @@ -598,12 +598,10 @@ * @throws Exception if an error occurs */ @Test - @Alerts(DEFAULT = {"C:\\fakepath\\pom.xml-Hello world-Hello world", - "<input type=\"file\" id=\"f\" value=\"Hello world\" multiple=\"\">"}, - FF = {"pom.xml-Hello world-Hello world", - "<input type=\"file\" id=\"f\" value=\"Hello world\" multiple=\"\">"}, - IE = {"§§PATH§§-Hello world-Hello world", - "<input type=\"file\" id=\"f\" value=\"Hello world\" multiple=\"\">"}) + @Alerts(DEFAULT = {"pom.xml-Hello world-Hello world", + "<input type=\"file\" id=\"f\" value=\"Hello world\" multiple=\"\">"}, + CHROME = {"C:\\fakepath\\pom.xml-Hello world-Hello world", + "<input type=\"file\" id=\"f\" value=\"Hello world\" multiple=\"\">"}) public void value() throws Exception { final String html = "<html>\n" Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlFileInputTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlFileInputTest.java 2017-08-07 07:34:47 UTC (rev 14771) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlFileInputTest.java 2017-08-07 18:17:45 UTC (rev 14772) @@ -458,9 +458,11 @@ * @throws Exception if an error occurs */ @Test - @Alerts(DEFAULT = "Content-Disposition: form-data; name=\"myInput\"; filename=\"realm.properties\"", - IE = "Content-Disposition: form-data; name=\"myInput\";" - + " filename=\".*test-classes[\\\\/]realm\\.properties\"") + @Alerts("Content-Disposition: form-data; name=\"myInput\"; filename=\"realm.properties\"") + // since 2.28 + // there is an option for IE, for local and trusted sites IE includes the file path + // because we do not support any IE specific setting we do not send the filename as + // done by the other browsers public void realFile() throws Exception { final String htmlContent = "<html>\n" @@ -1030,8 +1032,11 @@ */ @Test @Alerts(DEFAULT = "C:\\fakepath\\pom.xml--null", - FF = "pom.xml--null", - IE = "§§PATH§§--null") + FF = "pom.xml--null") + // since 2.28 + // there is an option for IE, for local and trusted sites IE includes the file path + // because we do not support any IE specific setting we do not send the filename as + // done by the other browsers public void value2() throws Exception { final String html = "<html>\n" @@ -1054,9 +1059,7 @@ driver.findElement(By.id("f")).sendKeys(absolutePath); driver.findElement(By.id("clickMe")).click(); - final String[] expectedAlerts = getExpectedAlerts(); - expectedAlerts[0] = expectedAlerts[0].replace("§§PATH§§", absolutePath); - assertEquals(expectedAlerts, getCollectedAlerts(driver)); + assertEquals(getExpectedAlerts(), getCollectedAlerts(driver)); } /** @@ -1111,8 +1114,11 @@ */ @Test @Alerts(DEFAULT = "C:\\fakepath\\pom.xml", - FF = "pom.xml", - IE = "§§PATH§§") + FF = "pom.xml") + // since 2.28 + // there is an option for IE, for local and trusted sites IE includes the file path + // because we do not support any IE specific setting we do not send the filename as + // done by the other browsers public void getAttribute() throws Exception { final String html = "<html><body>\n" @@ -1124,9 +1130,6 @@ final WebDriver driver = loadPage2(html); final WebElement e = driver.findElement(By.id("f")); e.sendKeys(absolutePath); - final String[] expectedAlerts = getExpectedAlerts(); - expectedAlerts[0] = expectedAlerts[0].replace("§§PATH§§", absolutePath); - assertEquals(expectedAlerts[0], e.getAttribute("value")); + assertEquals(getExpectedAlerts()[0], e.getAttribute("value")); } - } |