Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ZK-5475: select a date with time produces an invalid result under loc… #3203

Merged
merged 1 commit into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions zkdoc/release-note
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ ZK 10.1.0
ZK-5787: aria-hidden elements do not contain focusable elements
ZK-5743: clicking menuitem fires 2 onClick events in mobile browser
ZK-5594: ListboxDataLoader doGroupsDataChange finds incorrect offset, causes class cast exception
ZK-5475: select a date with time produces an invalid result under locale pt

* Upgrade Notes
+ Remove Htmls.encodeJavaScript(), Strings.encodeJavaScript(), Strings.escape() with Strings.ESCAPE_JAVASCRIPT, and replace them with OWASP Java Encoder APIs instead.
Expand Down
24 changes: 24 additions & 0 deletions zktest/src/main/webapp/test2/B101-ZK-5475.zul
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
B101-ZK-5475.zul

Purpose:

Description:

History:
2024/9/18, Created by jumperchen

Copyright (C) 2024 Potix Corporation. All Rights Reserved.

-->
<zk>
<label multiline="true">
1. The datebox should show the date "13 de junho de 2024 00:00:00".
2. Please change "00:00:00" to "00:00:01" and then blur the datebox.
3. If you see the date "13 de junho de 2024 00:00:01" in the datebox, the test is OK. Otherwise, any error happens it's a bug.
</label>
<datebox cols="30" format="d 'de' MMMM y HH:mm:ss" onCreate='self.valueInLocalDate = java.time.LocalDate.parse("2024-06-13")' locale="pt" />
</zk>

1 change: 1 addition & 0 deletions zktest/src/main/webapp/test2/config.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3136,6 +3136,7 @@ B90-ZK-4431.zul=A,E,Multislider
##zats##B101-ZK-5787.zul=A,E,WCAG,Accessibility,Focus,Tabindex,Aria-hidden
##zats##B101-ZK-5743.zul=A,E,Compressed,JS,Debug-JS,TabletUI,Mobile,onClick
##zats##B101-ZK-5594.zul=A,E,Group,ListGroup,ROD,zkmax,Exception
##zats##B101-ZK-5475.zul=A,E,Datebox,PT,Locale,Format,Constraint

##
# Features - 3.0.x version
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/* B101_ZK_5475Test.java

Purpose:

Description:

History:
2:48 PM 2024/9/18, Created by jumperchen

Copyright (C) 2024 Potix Corporation. All Rights Reserved.
*/
package org.zkoss.zktest.zats.test2;

import static org.junit.jupiter.api.Assertions.assertEquals;

import org.junit.jupiter.api.Test;

import org.zkoss.test.webdriver.WebDriverTestCase;

/**
* @author jumperchen
*/
public class B101_ZK_5475Test extends WebDriverTestCase {
@Test
public void test() {
connect();
assertEquals("13 de junho 2024 00:00:00", jq(".z-datebox-input").val());
type(jq(".z-datebox-input"), "13 de junho 2024 00:00:01");
blur(jq(".z-datebox-input"));
waitResponse(true);
assertEquals(0, jq(".z-errorbox").length());
assertEquals("13 de junho 2024 00:00:01", jq(".z-datebox-input").val());
}
}
2 changes: 2 additions & 0 deletions zul/src/main/resources/web/js/zul/db/datefmt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,8 @@ var DateFmt = {
era = eras[eraKey];
}

fmt = fmt.replace(/'.*?'/g, ' '); //ZK-5475 remove any string enclosed by single quotes

var refDate = refval._moment.toDate(),
localeDateTimeFormat = new Intl.DateTimeFormat(localizedSymbols.LAN_TAG, { year: 'numeric' }),
eraName = localizedSymbols.ERA || (eraKey ? eraKey : this.getEraName(refDate, localizedSymbols, localeDateTimeFormat)),
Expand Down
Loading