Skip to content

Commit ffc0acd

Browse files
committed
/series/import/request: increase max length of a URL to 285.
While 255 characters should be enough for a URL, if it contains non-ASCII symbols, it gets encoded and the result is greater than 255 characters. To handle this case, I increased the max length of a URL. See: https://en.wikipedia.org/wiki/Percent-encoding
1 parent 29f6dc9 commit ffc0acd

File tree

4 files changed

+34
-3
lines changed

4 files changed

+34
-3
lines changed

src/main/java/ru/mystamps/web/Db.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public static final class Series {
4141
}
4242

4343
public static final class SeriesImportRequest {
44-
public static final int URL_LENGTH = 255;
44+
public static final int URL_LENGTH = 285;
4545
}
4646

4747
public static final class SuspiciousActivity {

src/main/resources/liquibase/version/0.4.xml

+1
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,6 @@
3333
<include file="0.4/2017-10-31--series_sales_null_second_currency.xml" relativeToChangelogFile="true" />
3434
<include file="0.4/2017-10-31--non_nullable_catalog_codes.xml" relativeToChangelogFile="true" />
3535
<include file="0.4/2017-11-08--import_series.xml" relativeToChangelogFile="true" />
36+
<include file="0.4/2017-11-09--series_import_requests_url_length.xml" relativeToChangelogFile="true" />
3637

3738
</databaseChangeLog>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<databaseChangeLog
3+
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
6+
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.0.xsd">
7+
8+
<changeSet id="modify-series_import_requests-charset" author="php-coder" context="scheme" dbms="mysql">
9+
<!--
10+
Fix for "liquibase.exception.DatabaseException:
11+
Specified key was too long; max key length is 767 bytes
12+
[Failed SQL: ALTER TABLE mystamps.series_import_requests MODIFY url VARCHAR(285)]".
13+
See also: https://stackoverflow.com/questions/1814532/1071-specified-key-was-too-long-max-key-length-is-767-bytes
14+
-->
15+
<comment>
16+
Change character set from utf8 to ascii for a URL field to be able to have a unique
17+
constraint on a field that has length greater than 255 characters.
18+
</comment>
19+
20+
<sql>
21+
ALTER TABLE series_import_requests DEFAULT CHARACTER SET ascii
22+
</sql>
23+
24+
</changeSet>
25+
26+
<changeSet id="modify-series_import_requests-url-field" author="php-coder" context="scheme">
27+
<modifyDataType tableName="series_import_requests" columnName="url" newDataType="VARCHAR(285)" />
28+
</changeSet>
29+
30+
</databaseChangeLog>

src/test/robotframework/series/import/validation.robot

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ Submit request with blank required field
1515
Submit request with too long url
1616
[Documentation] Verify validation of too long url
1717
${letter}= Set Variable j
18-
Input Text id=url http://${letter * 255}
18+
Input Text id=url http://${letter * 285}
1919
Submit Form id=import-series-form
20-
Element Text Should Be id=url.errors Value is greater than allowable maximum of 255 characters
20+
Element Text Should Be id=url.errors Value is greater than allowable maximum of 285 characters
2121

2222
Submit request with invalid url
2323
[Documentation] Verify validation of invalid url

0 commit comments

Comments
 (0)