CN113672838A - Code repairing method and device, electronic equipment and storage medium - Google Patents

Code repairing method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN113672838A
CN113672838A CN202111005496.8A CN202111005496A CN113672838A CN 113672838 A CN113672838 A CN 113672838A CN 202111005496 A CN202111005496 A CN 202111005496A CN 113672838 A CN113672838 A CN 113672838A
Authority
CN
China
Prior art keywords
code
repair
error
request
repairing
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202111005496.8A
Other languages
Chinese (zh)
Inventor
甘振文
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guahao Net Hangzhou Technology Co Ltd
Original Assignee
Guahao Net Hangzhou Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Guahao Net Hangzhou Technology Co Ltd filed Critical Guahao Net Hangzhou Technology Co Ltd
Priority to CN202111005496.8A priority Critical patent/CN113672838A/en
Publication of CN113672838A publication Critical patent/CN113672838A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/958Organisation or management of web site content, e.g. publishing, maintaining pages or automatic linking
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/362Software debugging
    • G06F11/3628Software debugging of optimised code

Abstract

The application provides a code repairing method, a device, an electronic device and a storage medium, wherein the method comprises the following steps: receiving a code repair request of a page script file sent by a client; the code repairing request comprises a code error file link, a code error position and a code error type; determining a code repair method according to the code repair request, and repairing an error code according to the code repair method; and returning a repair completion notification to the client after the repair is completed, and triggering the client to reload the page script file. According to the technical scheme provided by the embodiment of the application, the error codes in the webpage script file can be repaired, so that a user can normally access the Web system, and the webpage can normally operate.

Description

Code repairing method and device, electronic equipment and storage medium
Technical Field
The present application relates to the field of computer technologies, and in particular, to a code recovery method and apparatus, an electronic device, and a storage medium.
Background
The user accesses the Web system through the browser, all interactions of the Web system cannot leave JavaScript, and the JavaScript plays a role in data transmission, so that if the JavaScript stops running, the Web page stops working, and the user is influenced to access the Web system.
In the prior art, JavaScript runs in an engine, different browser manufacturers configure different engines, but JavaScript cannot adapt to all engines, and JavaScript is a weak type language, so that JavaScript is prone to code errors.
Disclosure of Invention
The embodiment of the application aims to provide a code repairing method for repairing codes of a page script file.
The embodiment of the application provides a code repairing method, which comprises the following steps:
receiving a code repair request of a page script file sent by a client; the code repairing request comprises a code error file link, a code error position and a code error type;
determining a code repair method according to the code repair request, and repairing an error code according to the code repair method;
and after the repair is finished, returning a repair completion notification to the client, and triggering the client to reload the page script file.
In one embodiment, determining a code repair method according to the code repair request and repairing the error code according to the code repair method includes:
and searching a regular expression corresponding to the code error type according to the code error type indicated by the code repairing request, and repairing the error code according to the regular expression.
In an embodiment, before receiving a code repair request of a page script file sent by a client, the method further includes:
regular expressions corresponding to code error types are received.
The embodiment of the application provides a code repairing method, which comprises the following steps:
when the page script file has an error report, sending a code repair request to a server; the code repairing request comprises a code error file link, a code error position and a code error type;
receiving a repair completion notification returned by the server according to the code repair request;
and reloading the page script file from the server side in response to the repair completion notification.
In an embodiment, when an error occurs in a page script file, before sending a code repair request to a server, the method further includes:
registering an error triggering event;
and when an error triggering event is detected, determining that the page script file has an error report.
The embodiment of the application provides a code repairing method, which comprises the following steps:
when a page script file of a client side has an error report, the client side sends a code repair request to a server side; the code repairing request comprises a code error file link, a code error position and a code error type;
the server side determines a code repairing method according to the code repairing request and repairs the error code according to the code repairing method;
and the client receives a repair completion notification returned by the server according to the code repair request, and reloads the page script file from the server in response to the repair completion notification.
An embodiment of the present application provides a code recovery apparatus, including:
the first receiving module is used for receiving a code repair request of the page script file sent by the client; the code repairing request comprises a code error file link, a code error position and a code error type;
the repair module is used for determining a code repair method according to the code repair request and repairing an error code according to the code repair method;
and the notification module is used for returning a repair completion notification to the client after the repair is completed and triggering the client to reload the page script file.
An embodiment of the present application provides a code recovery apparatus, including:
the sending module is used for sending a code repair request to the server side when the page script file has an error report; the code repairing request comprises a code error file link, a code error position and a code error type;
the second receiving module is used for receiving a repair completion notification returned by the server according to the code repair request;
and the loading module is used for responding to the repair completion notice and reloading the page script file from the server.
An embodiment of the present application provides an electronic device, including:
a processor;
a memory for storing processor-executable instructions;
wherein the processor is configured to perform the code repair method described above.
The embodiment of the application provides a computer readable storage medium, and the storage medium stores a computer program which can be executed by a processor to complete the code repairing method.
According to the technical scheme provided by the embodiment of the application, the code error type can be determined through the code repairing request, and the error code is repaired according to the regular expression corresponding to the code error type, so that the user cannot be influenced to access the page, and the webpage can normally operate.
Drawings
In order to more clearly explain the technical solutions of the embodiments of the present application, the drawings needed to be used in the embodiments of the present application will be briefly described below, it should be understood that the following drawings only illustrate some embodiments of the present application and therefore should not be considered as limiting the scope, and that for those skilled in the art, other related drawings can be obtained from these drawings without inventive effort.
Fig. 1 is a schematic view of an application scenario of a code recovery method according to an embodiment of the present application;
fig. 2 is a schematic structural diagram of an electronic device according to an embodiment of the present application;
FIG. 3 is a flowchart illustrating a code recovery method according to an embodiment of the present application;
FIG. 4 is a block diagram of a code recovery apparatus according to an embodiment of the present application;
fig. 5 is a block diagram of a code recovery apparatus according to an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be described below with reference to the drawings in the embodiments of the present application.
Like reference numbers and letters refer to like items in the following figures, and thus, once an item is defined in one figure, it need not be further defined and explained in subsequent figures. Meanwhile, in the description of the present application, the terms "first", "second", and the like are used only for distinguishing the description, and are not to be construed as indicating or implying relative importance.
Fig. 1 is a schematic view of an application scenario of a code recovery method according to an embodiment of the present application. As shown in fig. 1, the method may include a client 10 and a server 20. The client 10 may be a smart phone, a notebook computer, a desktop computer, or the like, and the server 20 may be a desktop computer, or the like. The client 10 and the server 20 are connected via a wired or wireless network. The client 10 and the server 20 can be used to execute the code recovery method described below.
Fig. 2 is a schematic structural diagram of an electronic device according to an embodiment of the present application. The electronic device 30 may be the client 10 or the server 20, and the electronic device 30 may be configured to execute the code recovery method provided by the embodiment of the present application. As shown in fig. 2, the electronic device 30 includes: one or more processors 33, one or more memories 31 storing processor-executable instructions, the processors 33 and the memories 31 being connected by a bus 32. Wherein the processor 33 is configured to execute the code repairing method provided by the following embodiments of the present application.
The processor 33 may be a device containing a Central Processing Unit (CPU), a Graphics Processing Unit (GPU) or other form of processing unit having data processing and/or instruction execution capabilities, may process data for other components in the electronic device 30, and may control other components in the electronic device 30 to perform desired functions.
The memory 31 may include one or more computer program products that may include various forms of computer-readable storage media, such as volatile memory and/or non-volatile memory. The volatile memory may include, for example, Random Access Memory (RAM), cache memory (cache), and/or the like. The non-volatile memory may include, for example, Read Only Memory (ROM), hard disk, flash memory, etc. One or more computer program instructions may be stored on the computer-readable storage medium and executed by the processor 33 to implement the code repair method described below. Various applications and various data, such as various data used and/or generated by the applications, may also be stored in the computer-readable storage medium.
Fig. 3 is a flowchart illustrating a code recovery method according to an embodiment of the present application. As shown in fig. 3, the method may include the following steps S210-S230.
Step S210: when the page script file of the client has an error report, the client sends a code repair request to the server; the code repair request comprises an error file link, a code error position and a code error type.
When a user accesses the Web system, the error reporting phenomenon may occur in the page script file in the Web system, so that the Web system stops operating and the user accesses the Web system is affected. The page script file is composed of JavaScript codes, so error codes of the JavaScript are required to be repaired.
When the page script file of the client side has an error report, the client side sends a code repair request to the server side, wherein the code repair request comprises an error file link, a code error position and a code error type; the error file link and the code error position can help the server to accurately position the error code position, and the code error type is convenient for the server to determine the code error type of the error code, so that the server can better repair the error code.
The method for determining the error report phenomenon of the page script file by the client comprises the following steps:
and registering an error triggering event by the client, and determining that the page script file has an error report when the error triggering event is detected.
The error triggering event is an operation event registered by the client, and means that when the error reporting phenomenon occurs in the page script file in the client, the operation event is triggered, so that when the error triggering event is detected, the client can determine that the page script file has an error report.
Step S220: and the server determines a code repair method according to the code repair request and repairs the error code according to the code repair method.
The specific method for the server side to repair the error code is as follows:
and the server side searches a regular expression corresponding to the code error type according to the code error type indicated by the code repairing request, and repairs the error code according to the regular expression.
The method comprises the steps that a server side analyzes a code repairing request after receiving the code repairing request, code error positions and code error types are determined, each code error type corresponds to one code repairing method, the repairing method in the application is that regular expressions are used for repairing error codes, each code error type is provided with a corresponding regular expression, and a specific repairing means is that searching and replacing are carried out through the regular expressions.
For example, the types of common code errors and the repair method in the page script file are as follows:
(1) uncaught URIError: when the error reporting phenomenon occurs in the running process of the page script file, the page script file is proved to have URI errors, and the repairing method at the moment is that the regular expression is positioned to the position of an error code through a code repairing request, and the error code is replaced by a null statement to delete the URI error code, so that the page script file can run normally;
(2) uncaught Syntax Error: when the error reporting phenomenon occurs in the running process of the page script file, the page script file is proved to have reference errors, namely the referenced object attribute exists in the code and the object of the referenced object attribute is null, the repairing method is that the regular expression is positioned to the position of an error code through a code repairing request, and a judging statement is added at the referenced object attribute in the code, so that when the page script file executes the operation of the referenced object attribute, whether the object of the referenced object attribute is null or not is judged firstly, and only when the object exists, the operation of the referenced object attribute is executed;
(3) uncaught type error: when the error reporting phenomenon occurs in the running process of the page script file, the page script file is proved to have an overflow error, namely the actual size of a variable is larger than the size of a storage space allocated to the page script file by a client, so that the variable overflow phenomenon occurs;
(4) uncaught Range error: when the error reporting phenomenon occurs in the running process of the page script file, the page script file is proved to have assignment errors, for example, a variable A and a variable B exist in the page script file, the assignment of the variable B depends on the variable A, but the variable A is not assigned in the script file, so the error reporting phenomenon occurs; the restoration method comprises the steps that a regular expression is positioned at the position of an error code through a code restoration request, and a judgment statement is added at a variable B in the code, so that when a page script file executes an assignment statement, whether the variable A is subjected to assignment operation or not is judged, and only when the variable A is subjected to assignment operation, the assignment operation on the variable B is executed, so that the assignment error is eliminated;
(5) uncaught ReferenceError: when the error reporting phenomenon occurs in the running process of the page script file, the page script file is proved to have URI errors, and the repairing method at the moment is that the regular expression is positioned to the position of an error code through a code repairing request, and the error code is replaced by a null statement to delete the URI error code, so that the page script file can run normally;
(6) uncaught EvalError: when the error reporting phenomenon occurs in the running process of the page script file, the page script file is proved to have an Eval grammar error, the repairing method at the moment is that the regular expression is positioned to the position of an error code through a code repairing request, and an Eval statement is replaced by a null statement to delete the Eval error code so as to eliminate the Eval grammar error.
Therefore, the regular expression can be used for repairing error codes in the page script file, so that the page script file can normally operate, and a user can normally access the Web system.
Step S230: and the client receives a repair completion notification returned by the server according to the code repair request, and the client reloads the page script file from the server in response to the repair completion notification.
And after the server side finishes repairing, a repairing completion notice is returned to the client side so as to trigger the client side to reload the page script file, so that the webpage can run normally.
An embodiment of the present application provides a code recovery method, which recovers an error code in a script file of a Web page through a regular expression, so that a user can normally access a Web system, and the Web page can normally operate.
Fig. 4 is a block diagram of a code recovery apparatus according to an embodiment of the present application. As shown in fig. 4, the apparatus includes a first receiving module 310, a repairing module 320, and a notifying module 330.
A first receiving module 310, configured to receive a code repair request of a page script file sent by a client; the code repairing request comprises a code error file link, a code error position and a code error type;
a repair module 320, configured to determine a code repair method according to the code repair request, and repair an error code according to the code repair method;
and the notification module 330 is configured to return a repair completion notification to the client after the repair is completed, and trigger the client to reload the page script file.
Fig. 5 is a block diagram of a code recovery apparatus according to an embodiment of the present application. As shown in fig. 5, the apparatus includes a sending module 410, a second receiving module 420, and a loading module 430.
A sending module 410, configured to send a code repair request to the server when an error occurs in the page script file; the code repairing request comprises a code error file link, a code error position and a code error type;
a second receiving module 420, configured to receive a repair completion notification returned by the server according to the code repair request;
and the loading module 430 is used for reloading the page script file from the server side in response to the repair completion notification.
The implementation process of the functions and actions of each module in the above device is specifically described in the implementation process of the corresponding step in the above code recovery method, and is not described herein again.
In the several embodiments provided in the present application, the disclosed apparatus and method can be implemented in other ways. The apparatus embodiments described above are merely illustrative, and for example, the flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods and computer program products according to various embodiments of the present application. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). In some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
In addition, the functional modules in the embodiments of the present application may be integrated together to form an independent part, or each module may exist alone, or two or more modules may be integrated to form an independent part.
The functions, if implemented in the form of software functional modules and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present application or portions thereof that substantially contribute to the prior art may be embodied in the form of a software product stored in a storage medium and including instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present application. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.

Claims (10)

1. A method for code repair, the method comprising:
receiving a code repair request of a page script file sent by a client; the code repairing request comprises a code error file link, a code error position and a code error type;
determining a code repair method according to the code repair request, and repairing an error code according to the code repair method;
and after the repair is finished, returning a repair completion notice to the client, and triggering the client to reload the page script file.
2. The code repair method of claim 1, wherein determining a code repair method according to the code repair request and repairing an error code according to the code repair method comprises:
and searching a regular expression corresponding to the code error type according to the code error type indicated by the code repairing request, and repairing the error code according to the regular expression.
3. The code repair method of claim 2, wherein before receiving a code repair request of the page script file sent by the client, the method further comprises:
receiving the regular expression corresponding to the code error type.
4. A method for code repair, the method comprising:
when the page script file has an error report, sending a code repair request to a server; the code repairing request comprises a code error file link, a code error position and a code error type;
receiving a repair completion notification returned by the server according to the code repair request;
and reloading the page script file from the server in response to the repair completion notification.
5. The code repair method according to claim 4, wherein before sending a code repair request to the server when the page script file has an error, the method further comprises:
registering an error triggering event;
and when the error triggering event is detected, determining that the page script file has an error report.
6. A method for code repair, the method comprising:
when a page script file of a client side has an error report, the client side sends a code repair request to a server side; the code repairing request comprises a code error file link, a code error position and a code error type;
the server side determines a code repairing method according to the code repairing request and repairs error codes according to the code repairing method;
and the client receives a repair completion notification returned by the server according to the code repair request, and reloads the page script file from the server in response to the repair completion notification.
7. A code recovery apparatus, the apparatus comprising:
the first receiving module is used for receiving a code repair request of the page script file sent by the client; the code repairing request comprises a code error file link, a code error position and a code error type;
the repair module is used for determining a code repair method according to the code repair request and repairing an error code according to the code repair method;
and the notification module is used for returning a repair completion notification to the client after the repair is completed and triggering the client to reload the page script file.
8. A code recovery apparatus, the apparatus comprising:
the sending module is used for sending a code repair request to the server side when the page script file has an error report; the code repairing request comprises a code error file link, a code error position and a code error type;
a second receiving module, configured to receive a repair completion notification returned by the server according to the code repair request;
and the loading module is used for responding to the repair completion notice and reloading the page script file from the server.
9. An electronic device, characterized in that the electronic device comprises:
a processor;
a memory for storing processor-executable instructions;
wherein the processor is configured to perform the code repair method of any one of claims 1-3.
10. A computer-readable storage medium, characterized in that the storage medium stores a computer program executable by a processor to perform the code repair method of any one of claims 1-3.
CN202111005496.8A 2021-08-30 2021-08-30 Code repairing method and device, electronic equipment and storage medium Pending CN113672838A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111005496.8A CN113672838A (en) 2021-08-30 2021-08-30 Code repairing method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111005496.8A CN113672838A (en) 2021-08-30 2021-08-30 Code repairing method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN113672838A true CN113672838A (en) 2021-11-19

Family

ID=78547406

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111005496.8A Pending CN113672838A (en) 2021-08-30 2021-08-30 Code repairing method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN113672838A (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20110083183A1 (en) * 2009-10-02 2011-04-07 International Business Machines Corporation Analysis of scripts
CN108459962A (en) * 2018-01-23 2018-08-28 平安普惠企业管理有限公司 Code specification detection method, device, terminal device and storage medium
US20190287029A1 (en) * 2018-03-16 2019-09-19 International Business Machines Corporation Classifying code as introducing a bug or not introducing a bug to train a bug detection algorithm
CN110837429A (en) * 2019-10-12 2020-02-25 平安科技(深圳)有限公司 Intelligent repairing method and device for online codes of web terminal

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20110083183A1 (en) * 2009-10-02 2011-04-07 International Business Machines Corporation Analysis of scripts
CN108459962A (en) * 2018-01-23 2018-08-28 平安普惠企业管理有限公司 Code specification detection method, device, terminal device and storage medium
US20190287029A1 (en) * 2018-03-16 2019-09-19 International Business Machines Corporation Classifying code as introducing a bug or not introducing a bug to train a bug detection algorithm
CN110837429A (en) * 2019-10-12 2020-02-25 平安科技(深圳)有限公司 Intelligent repairing method and device for online codes of web terminal

Similar Documents

Publication Publication Date Title
CN109474488B (en) Interface testing method and device and computer equipment
US10613970B1 (en) Method and system for managing deployment of software application components based on software performance data
CN110647320A (en) Project framework construction method and device, computer equipment and storage medium
US11093319B2 (en) Automated recovery of webpage functionality
US10990514B2 (en) Detecting problematic code changes
CN110221959B (en) Application program testing method, device and computer readable medium
CN110866258A (en) Method for quickly positioning bug, electronic device and storage medium
CN112417240A (en) Website link detection method and device and computer equipment
CN110704297A (en) Code evaluation method and device, computer equipment and storage medium
CN110716878A (en) Automatic interface testing method, device and system
CN108038020B (en) Webpage fault tracking method and device, electronic equipment and computer storage medium
CN113448862A (en) Software version testing method and device and computer equipment
CN109697158B (en) Log analysis method and device based on fault
CN108241543B (en) Method, service server and system for executing service operation breakpoint
CN112540925A (en) New characteristic compatibility detection system and method, electronic device and readable storage medium
CN113672838A (en) Code repairing method and device, electronic equipment and storage medium
CN111756594B (en) Control method of pressure test, computer device and computer readable storage medium
CN113900663B (en) Data processing method and device
CN116521405A (en) sd card state detection method, device, equipment and storage medium
CN110362464B (en) Software analysis method and equipment
CN114546799A (en) Point burying log checking method and device, electronic equipment, storage medium and product
CN110231921B (en) Log printing method, device, equipment and computer readable storage medium
CN109740386B (en) Method and device for detecting static resource file
CN113419949A (en) Data processing abnormity detection method, device, equipment and storage medium
CN112579858A (en) Data crawling method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination