undefect. CWE-407 — 63 sites patched across 27 ecosystems
Authors: russell@unturf.com · brackishbert@gmail.com · foxhop.net · TimeHexOn.com Patches, unit tests, benchmarks, whitepaper, and outreach briefs. Public domain — no copyright claimed. Use freely.
This commit is contained in:
commit
0a580b313d
70422 changed files with 17213626 additions and 0 deletions
|
|
@ -0,0 +1,123 @@
|
|||
/*
|
||||
* Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import jdk.test.lib.Platform;
|
||||
import java.awt.GridLayout;
|
||||
import java.awt.TextArea;
|
||||
import java.awt.TextField;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8000423 7197619 8025649
|
||||
* @summary Check if diacritical signs could be typed for TextArea and TextField
|
||||
* @requires (os.family == "windows" | os.family == "linux")
|
||||
* @library /java/awt/regtesthelpers /test/lib
|
||||
* @build PassFailJFrame jdk.test.lib.Platform
|
||||
* @run main/manual DiacriticsTest
|
||||
*/
|
||||
|
||||
public class DiacriticsTest {
|
||||
|
||||
private static final String INSTRUCTIONS_WIN = """
|
||||
Test run requires the following keyboard layouts to be installed:
|
||||
- Hungarian
|
||||
- A keyboard layout having compose function or compose-like key. Programmer
|
||||
Dvorak (http://www.kaufmann.no/roland/dvorak/) is suggested to use.
|
||||
|
||||
To the right are a text area and a text field, you should check the behavior
|
||||
for both of them.
|
||||
|
||||
To test the JDK-7197619 fix:
|
||||
Please switch to Hungarian keyboard layout and try to type diacritics
|
||||
(Ctrl+Alt+2 e; Ctrl+Alt+2 E)
|
||||
|
||||
To test the JDK-8139189 fix:
|
||||
Please switch to Programmer Dvorak keyboard layout try to type diacritics
|
||||
using compose combinations (Compose+z+d, Compose+z+Shift+d).
|
||||
|
||||
The Compose key in the Programmer Dvorak layout is OEM102, the key located
|
||||
between the and Z keys on a standard 102-key keyboard.
|
||||
If you do not have this key on your keyboard, you can skip this part of the test.
|
||||
|
||||
If you can do that then the test is passed; otherwise failed.
|
||||
""";
|
||||
|
||||
private static final String INSTRUCTIONS_LIN = """
|
||||
Test run requires the following keyboard layouts to be installed:
|
||||
- English (US, alternative international), aka English (US, alt. intl.)
|
||||
- A keyboard layout having compose function or compose-like key. Programmer
|
||||
Dvorak (http://www.kaufmann.no/roland/dvorak/) is suggested to use.
|
||||
|
||||
To the right are a text area and a text field, you should check the behavior
|
||||
for both of them.
|
||||
|
||||
To test the JDK-8000423 fix:
|
||||
Please switch to US alternative international layout and try to type diacritics
|
||||
(using the following combinations: `+e; `+u; etc.)
|
||||
|
||||
To test the JDK-8139189 fix:
|
||||
Please switch to Programmer Dvorak keyboard layout try to type diacritics
|
||||
using compose combinations (Compose+z+d, Compose+z+Shift+d)..
|
||||
|
||||
The Compose key in the Programmer Dvorak layout is OEM102, the key located
|
||||
between the and Z keys on a standard 102-key keyboard.
|
||||
|
||||
If the above key does not work in the Gnome shell,
|
||||
it can be overridden in the system preferences:
|
||||
System > Keyboard > Special character entry > Compose key
|
||||
and set it to another key(e.g. menu key or scroll lock.)
|
||||
|
||||
If you can do that then the test is passed; otherwise failed.
|
||||
""";
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
String instructions = Platform.isWindows()
|
||||
? INSTRUCTIONS_WIN
|
||||
: INSTRUCTIONS_LIN;
|
||||
|
||||
PassFailJFrame
|
||||
.builder()
|
||||
.title("DiacriticsTest Instructions")
|
||||
.instructions(instructions)
|
||||
.splitUIRight(DiacriticsTest::createPanel)
|
||||
.testTimeOut(10)
|
||||
.rows((int) instructions.lines().count() + 2)
|
||||
.columns(50)
|
||||
.build()
|
||||
.awaitAndCheck();
|
||||
}
|
||||
|
||||
public static JPanel createPanel() {
|
||||
JPanel panel = new JPanel();
|
||||
panel.setLayout(new GridLayout(2, 1));
|
||||
|
||||
TextArea txtArea = new TextArea();
|
||||
panel.add(txtArea);
|
||||
|
||||
TextField txtField = new TextField();
|
||||
panel.add(txtField);
|
||||
|
||||
return panel;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,144 @@
|
|||
/*
|
||||
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/* @test
|
||||
* @bug 8177414
|
||||
* @summary KEY_PRESSED and KEY_TYPED events are not generated if a key's held
|
||||
* @library ../../regtesthelpers
|
||||
* @build Util
|
||||
* @run main/manual InputMethodKeyEventsTest
|
||||
*/
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.KeyListener;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import test.java.awt.regtesthelpers.Util;
|
||||
|
||||
public class InputMethodKeyEventsTest {
|
||||
private static final AtomicBoolean testCompleted = new AtomicBoolean(false);
|
||||
private static volatile boolean testResult = false;
|
||||
|
||||
private static Dialog controlDialog;
|
||||
private static Frame testFrame;
|
||||
|
||||
private static final String instructions =
|
||||
"Verify that KEY_PRESSED and KEY_TYPED events are generated after a key's " +
|
||||
"\npressed and held.\n" +
|
||||
"\nThis test is for OS X only. For other platforms please simply press \"Pass\".\n" +
|
||||
"\n1. Go to \"System Preferences -> Keyboard -> Input Sources\" and add \"British\" IM." +
|
||||
"\n2. Set current IM to \"British\"." +
|
||||
"\n3. Set focus to the frame located at north-west corner." +
|
||||
"\n4. Pres and hold the \"i\" key for 3 seconds." +
|
||||
"\n5. Press and release the \"i\" key again. Use log area to ensure that " +
|
||||
"\n KEY_TYPED and KEY_PRESSED events are still generated." +
|
||||
"\nIf KEY_PRESSED, KEY_TYPED and KEY_RELEASED are generated for every key press then " +
|
||||
"\npress \"Pass\", otherwise press \"Fail\".";
|
||||
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
Robot robot = Util.createRobot();
|
||||
|
||||
createAndShowGUI();
|
||||
Util.waitForIdle(robot);
|
||||
|
||||
Util.waitForCondition(testCompleted);
|
||||
if (!testResult) {
|
||||
throw new RuntimeException("Test FAILED!");
|
||||
}
|
||||
} finally {
|
||||
if (controlDialog != null) {
|
||||
controlDialog.dispose();
|
||||
}
|
||||
if (testFrame != null) {
|
||||
testFrame.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void createAndShowGUI() {
|
||||
controlDialog = new Dialog((Frame)null, "InputMethodKeyEventsTest");
|
||||
|
||||
TextArea messageArea = new TextArea(instructions, 15, 80, TextArea.SCROLLBARS_BOTH);
|
||||
controlDialog.add("North", messageArea);
|
||||
|
||||
TextArea logArea = new TextArea("Test's logs are displayed here\n", 15, 80, TextArea.SCROLLBARS_BOTH);
|
||||
controlDialog.add("Center", logArea);
|
||||
|
||||
Button passedButton = new Button("Pass");
|
||||
passedButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
testResult = true;
|
||||
completeTest();
|
||||
}
|
||||
});
|
||||
|
||||
Button failedButton = new Button("Fail");
|
||||
failedButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
testResult = false;
|
||||
completeTest();
|
||||
}
|
||||
});
|
||||
|
||||
Panel buttonPanel = new Panel();
|
||||
buttonPanel.add("West",passedButton);
|
||||
buttonPanel.add("East", failedButton);
|
||||
controlDialog.add("South", buttonPanel);
|
||||
|
||||
controlDialog.setBounds(250, 0, 500, 500);
|
||||
controlDialog.setVisible(true);
|
||||
|
||||
testFrame = new Frame("InputMethodKeyEventsTest");
|
||||
testFrame.setSize(200, 200);
|
||||
testFrame.addKeyListener(new KeyListener() {
|
||||
@Override
|
||||
public void keyTyped(KeyEvent e) {
|
||||
logArea.append("KEY_TYPED keyCode = " + e.getKeyCode() + "\n");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyPressed(KeyEvent e) {
|
||||
logArea.append("KEY_PRESSED keyCode = " + e.getKeyCode() + "\n");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyReleased(KeyEvent e) {
|
||||
logArea.append("KEY_RELEASED keyCode = " + e.getKeyCode() + "\n");
|
||||
}
|
||||
});
|
||||
testFrame.setVisible(true);
|
||||
}
|
||||
|
||||
private static void completeTest() {
|
||||
testCompleted.set(true);
|
||||
synchronized (testCompleted) {
|
||||
testCompleted.notifyAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,97 @@
|
|||
/*
|
||||
* Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import java.awt.TextArea;
|
||||
import java.awt.TextField;
|
||||
import javax.swing.Box;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JComponent;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 7146572 8024122
|
||||
* @summary Check if 'enableInputMethods' works properly for TextArea and TextField on Linux platform
|
||||
* @requires (os.family == "linux")
|
||||
* @library /java/awt/regtesthelpers
|
||||
* @build PassFailJFrame
|
||||
* @run main/manual InputMethodsTest
|
||||
*/
|
||||
|
||||
public class InputMethodsTest {
|
||||
|
||||
private static final String INSTRUCTIONS = """
|
||||
Test run requires some Japanese input method to be installed.
|
||||
|
||||
To test the JDK-7146572 fix, please follow these steps:
|
||||
1. Enable the input method.
|
||||
2. Type Japanese in the text area and the text field to the right.
|
||||
2. Press the "Disable Input Methods" button.
|
||||
3. Try typing Japanese again.
|
||||
4. If input methods are not disabled, then press fail;
|
||||
otherwise, press pass.
|
||||
""";
|
||||
|
||||
static boolean inputMethodsEnabled = true;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
PassFailJFrame
|
||||
.builder()
|
||||
.title("InputMethodsTest Instructions")
|
||||
.instructions(INSTRUCTIONS)
|
||||
.splitUIRight(InputMethodsTest::createPanel)
|
||||
.testTimeOut(10)
|
||||
.rows(10)
|
||||
.columns(40)
|
||||
.build()
|
||||
.awaitAndCheck();
|
||||
}
|
||||
|
||||
public static JComponent createPanel() {
|
||||
Box verticalBox = Box.createVerticalBox();
|
||||
|
||||
TextArea textArea = new TextArea();
|
||||
verticalBox.add(textArea);
|
||||
|
||||
TextField textField = new TextField();
|
||||
verticalBox.add(textField);
|
||||
|
||||
JButton btnIM = new JButton();
|
||||
setBtnText(btnIM);
|
||||
|
||||
btnIM.addActionListener(e -> {
|
||||
inputMethodsEnabled = !inputMethodsEnabled;
|
||||
setBtnText(btnIM);
|
||||
textArea.enableInputMethods(inputMethodsEnabled);
|
||||
textField.enableInputMethods(inputMethodsEnabled);
|
||||
});
|
||||
|
||||
verticalBox.add(btnIM);
|
||||
return verticalBox;
|
||||
}
|
||||
|
||||
private static void setBtnText(JButton btnIM) {
|
||||
String s = inputMethodsEnabled ? "Disable" : "Enable";
|
||||
btnIM.setText(s + " Input Methods");
|
||||
}
|
||||
}
|
||||
|
||||
92
test/jdk/java/awt/InputMethods/SpanishDiacriticsTest.java
Normal file
92
test/jdk/java/awt/InputMethods/SpanishDiacriticsTest.java
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
/*
|
||||
* Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8169355
|
||||
* @summary Check if Spanish diacritical signs could be typed for TextField
|
||||
* @requires (os.family == "windows")
|
||||
* @library /java/awt/regtesthelpers
|
||||
* @run main/manual SpanishDiacriticsTest
|
||||
*/
|
||||
|
||||
|
||||
import java.util.concurrent.locks.LockSupport;
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.WindowConstants;
|
||||
|
||||
public class SpanishDiacriticsTest {
|
||||
|
||||
static final String INSTRUCTIONS = """
|
||||
This test requires the following keyboard layout to be installed:
|
||||
Windows OS: Spanish (United States) with 'Latin American' keyboard layout.
|
||||
If using a US layout, the results should still be as described but
|
||||
you have not tested the real bug.
|
||||
|
||||
1. A frame with a text field should be displayed.
|
||||
2. Set focus to the text field and switch to Spanish
|
||||
with 'Latin American' keyboard layout.
|
||||
3. Type the following: ' ' o - i.e. single quote two times, then o.
|
||||
If your keyboard has a US physical layout the [ key can be used
|
||||
to type the single quote when in 'Latin American' keyboard mode.
|
||||
4. Type these characters at a normal speed but do NOT be concerned
|
||||
that they take several seconds to display. That is an
|
||||
expected behaviour for this test.
|
||||
|
||||
If the text field displays the same three characters you typed: ''o
|
||||
(i.e. two single quotes followed by o without an acute)
|
||||
then press Pass; otherwise press Fail.
|
||||
""";
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
PassFailJFrame.builder()
|
||||
.title("Spanish Diacritics")
|
||||
.instructions(INSTRUCTIONS)
|
||||
.rows(20)
|
||||
.columns(50)
|
||||
.testUI(SpanishDiacriticsTest::createTestUI)
|
||||
.build()
|
||||
.awaitAndCheck();
|
||||
}
|
||||
|
||||
static JFrame createTestUI() {
|
||||
JFrame frame = new JFrame("Spanish Diacritics Test Frame");
|
||||
JTextField textField = new JTextField(20);
|
||||
textField.addKeyListener(new KeyAdapter() {
|
||||
@Override
|
||||
public void keyTyped(KeyEvent e) {
|
||||
LockSupport.parkNanos(1_000_000_000L);
|
||||
}
|
||||
});
|
||||
frame.add(textField);
|
||||
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
|
||||
frame.pack();
|
||||
return frame;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue