Commit 2b93731
committed
fix: address Cursor Bot security and correctness issues
Fix critical bugs identified by Cursor Bot code review:
1. **Missing body tag handling in Vite plugin**
- Added check for missing </body> tag (lastIndexOf returns -1)
- Prevents malformed HTML with script at wrong position
- Gracefully appends script at end if body tag not found
- Added debug logging for missing body tag case
2. **Contradictory loading content suggestion**
- Fixed confusing suggestion for loading selectors
- Now suggests waiting for loading to disappear THEN get content
- Provides alternative to wait for API request
- Clarifies when user actually needs the loading element itself
3. **Unescaped quotes in generated code suggestions**
- All selectors now properly escaped before interpolation
- Prevents syntax errors like: cy.get('[data-test='value']')
- Correctly generates: cy.get('[data-test=\\'value\\']')
- Applied to all suggestion types (dynamic, complex, ID, general)
Test coverage:
- Added tests for quote escaping in selectors
- Verified proper handling of special characters
- All 19 tests passing
- Lint checks passing
Before:
- cy.get('[data-test='value']') // SYNTAX ERROR
After:
- cy.get('[data-test=\\'value\\']') // VALID
Related: Security and code quality improvements1 parent 50d5920 commit 2b93731
File tree
3 files changed
+58
-10
lines changed- npm/vite-dev-server/src/plugins
- packages/driver
- src/cypress
- test/unit/cypress
3 files changed
+58
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
126 | 126 | | |
127 | 127 | | |
128 | 128 | | |
129 | | - | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
130 | 139 | | |
131 | 140 | | |
132 | 141 | | |
133 | 142 | | |
| 143 | + | |
134 | 144 | | |
135 | 145 | | |
136 | 146 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
| 81 | + | |
| 82 | + | |
81 | 83 | | |
82 | | - | |
| 84 | + | |
83 | 85 | | |
84 | | - | |
| 86 | + | |
| 87 | + | |
85 | 88 | | |
86 | | - | |
| 89 | + | |
87 | 90 | | |
88 | 91 | | |
89 | 92 | | |
90 | 93 | | |
91 | 94 | | |
92 | 95 | | |
93 | 96 | | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
94 | 100 | | |
95 | 101 | | |
96 | 102 | | |
97 | 103 | | |
98 | 104 | | |
99 | | - | |
| 105 | + | |
100 | 106 | | |
101 | 107 | | |
102 | 108 | | |
103 | 109 | | |
104 | 110 | | |
105 | 111 | | |
106 | 112 | | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
107 | 116 | | |
108 | 117 | | |
109 | 118 | | |
110 | 119 | | |
111 | 120 | | |
112 | | - | |
| 121 | + | |
113 | 122 | | |
114 | 123 | | |
115 | 124 | | |
| |||
190 | 199 | | |
191 | 200 | | |
192 | 201 | | |
| 202 | + | |
| 203 | + | |
193 | 204 | | |
194 | | - | |
| 205 | + | |
195 | 206 | | |
196 | 207 | | |
197 | 208 | | |
| |||
Lines changed: 30 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
21 | | - | |
22 | | - | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
23 | 34 | | |
24 | 35 | | |
25 | 36 | | |
| |||
228 | 239 | | |
229 | 240 | | |
230 | 241 | | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
231 | 258 | | |
232 | 259 | | |
233 | 260 | | |
| |||
0 commit comments