Home Web Front-end H5 Tutorial About the CCF CSP window

About the CCF CSP window

Sep 14, 2018 pm 02:02 PM

XSS cross-site scripting attack, bypassing the same origin policy through fake content and click bait. This is a big problem, and if an attacker successfully injects code, a considerable amount of user data can be leaked.

Problem Description

In a certain graphics operating system, there are N windows, each window is a rectangular area with both sides parallel to the coordinate axis. . Points on the boundary of the window also belong to the window. There are hierarchical differences between windows. In an area where more than one window overlaps, only the content in the top-level window will be displayed.
When you click a point on the screen, you select the top-level window at the clicked position, and this window will be moved to the top-level of all windows, while the hierarchical order of the remaining windows remains unchanged. If the location you click does not belong to any window, the system will ignore your click.
Now we want you to write a program to simulate the process of clicking on a window.

Input format

The first line of input contains two positive integers, namely N and M. (1 ≤ N ≤ 10,1 ≤ M ≤ 10)
 The next N lines give the positions of N windows in order from the bottom to the top. Each line contains four non-negative integers x1, y1, x2, y2, indicating a pair of vertex coordinates of the window (x1, y1) and (x2, y2). It is guaranteed that x1 < x2,y1 2.
Each of the next M lines contains two non-negative integers x and y, representing the coordinates of a mouse click.
The x and y coordinates of all points and the vertices of the rectangle involved in the question do not exceed 2559 and 1439 respectively.

Output format

The output includes M lines, each line represents the result of a mouse click. If a window is selected by this mouse click, the number of this window is output (windows are numbered from 1 to N in the order in the input); if not, "IGNORED" (without double quotes) is output.

Sample input

3 4
0 0 4 4
1 1 5 5
2 2 6 6
1 1
0 0
4 4
0 5

Sample output

2
1
1
IGNORED

Sample description

The position clicked for the first time belongs to both the 1st and 2nd windows, but since the 2nd window is on top, it is selected and brought to the top.
 The position clicked for the second time only belongs to the first window, so this click selects this window and brings it to the top. The hierarchical relationship between the three windows now is exactly the opposite of the initial state.
The position clicked for the third time belongs to the range of three windows at the same time, but since the first window is now at the top level, it is selected.
 The last clicked (0, 5) does not belong to any window.

Analysis: It is a very simple question, there is no difficulty, as long as the order is sorted out.

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

#include <iostream>

#include<vector>

using namespace std;

 

int main()

{

    int N, M;

    cin >> N >> M;

    vector<int>win;

    vector<int>::iterator it;

    for (int i = N; i > 0; i--)

    {

        win.push_back(i);

    }

    int position[11][4];

    int cli[13][2];

    for (int i = 1; i <= N; i++)

    {

        for (int j = 0; j < 4; j++)

        {

            cin >> position[i][j];

        }

    }

    for (int i = 0; i < M; i++)

    {

        for (int j = 0; j < 2; j++)//由于写这个的时候精神状态不是很好,原来写成j>2了。后来实在找不到哪里错了,只好把for循环重写了一遍。

        {

            cin >> cli[i][j];

        }

    }

    for (int i = 0; i < M; i++)

    {

        bool you = true;

        for (int j = 0; j < N; j++)

        {

            if (cli[i][0] >= position[win[j]][0] && cli[i][0] <= position[win[j]][2] && cli[i][1] >= position[win[j]][1] && cli[i][1] <= position[win[j]][3])

            {

                cout << win[j] << endl;

                you = false;

                if (j != 0)

                {

                    int a = win[j];

                    for (it = win.begin(); it != win.end();)

                    {

                        if (*it == a)

                        {

                            it = win.erase(it);

                        //  break;

                        }   //删除元素,返回值指向已删除元素的下一个位置

                        else

                        {

                            ++it;

                        }    //指向下一个位置

                    }

                    win.insert(win.begin(), a);

                }

                break;

            }

        }

        if (you)

        {

            cout << "IGNORED" << endl;

        }

         

    }

    return 0;

}

Copy after login

Related recommendations:

HTML5 Security Introduction Introduction to Content Security Policy (CSP)_html5 Tutorial Skills

html5 Basic tags (html5 video tag html5 new tag usage)_html5 tutorial skills

The above is the detailed content of About the CCF CSP window. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to run the h5 project How to run the h5 project Apr 06, 2025 pm 12:21 PM

Running the H5 project requires the following steps: installing necessary tools such as web server, Node.js, development tools, etc. Build a development environment, create project folders, initialize projects, and write code. Start the development server and run the command using the command line. Preview the project in your browser and enter the development server URL. Publish projects, optimize code, deploy projects, and set up web server configuration.

What exactly does H5 page production mean? What exactly does H5 page production mean? Apr 06, 2025 am 07:18 AM

H5 page production refers to the creation of cross-platform compatible web pages using technologies such as HTML5, CSS3 and JavaScript. Its core lies in the browser's parsing code, rendering structure, style and interactive functions. Common technologies include animation effects, responsive design, and data interaction. To avoid errors, developers should be debugged; performance optimization and best practices include image format optimization, request reduction and code specifications, etc. to improve loading speed and code quality.

How to make h5 click icon How to make h5 click icon Apr 06, 2025 pm 12:15 PM

The steps to create an H5 click icon include: preparing a square source image in the image editing software. Add interactivity in the H5 editor and set the click event. Create a hotspot that covers the entire icon. Set the action of click events, such as jumping to the page or triggering animation. Export H5 documents as HTML, CSS, and JavaScript files. Deploy the exported files to a website or other platform.

What application scenarios are suitable for H5 page production What application scenarios are suitable for H5 page production Apr 05, 2025 pm 11:36 PM

H5 (HTML5) is suitable for lightweight applications, such as marketing campaign pages, product display pages and corporate promotion micro-websites. Its advantages lie in cross-platformity and rich interactivity, but its limitations lie in complex interactions and animations, local resource access and offline capabilities.

What Does H5 Refer To? Exploring the Context What Does H5 Refer To? Exploring the Context Apr 12, 2025 am 12:03 AM

H5referstoHTML5,apivotaltechnologyinwebdevelopment.1)HTML5introducesnewelementsandAPIsforrich,dynamicwebapplications.2)Itsupportsmultimediawithoutplugins,enhancinguserexperienceacrossdevices.3)SemanticelementsimprovecontentstructureandSEO.4)H5'srespo

Is H5 page production a front-end development? Is H5 page production a front-end development? Apr 05, 2025 pm 11:42 PM

Yes, H5 page production is an important implementation method for front-end development, involving core technologies such as HTML, CSS and JavaScript. Developers build dynamic and powerful H5 pages by cleverly combining these technologies, such as using the &lt;canvas&gt; tag to draw graphics or using JavaScript to control interaction behavior.

What is the H5 programming language? What is the H5 programming language? Apr 03, 2025 am 12:16 AM

H5 is not a standalone programming language, but a collection of HTML5, CSS3 and JavaScript for building modern web applications. 1. HTML5 defines the web page structure and content, and provides new tags and APIs. 2. CSS3 controls style and layout, and introduces new features such as animation. 3. JavaScript implements dynamic interaction and enhances functions through DOM operations and asynchronous requests.

How to make pop-up windows with h5 How to make pop-up windows with h5 Apr 06, 2025 pm 12:12 PM

H5 pop-up window creation steps: 1. Determine the triggering method (click, time, exit, scroll); 2. Design content (title, text, action button); 3. Set style (size, color, font, background); 4. Implement code (HTML, CSS, JavaScript); 5. Test and deployment.

See all articles