Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
854c29b
feat: add hardened regex core and bounded evaluation
ItsWanheda Oct 22, 2026
57b4d49
feat: add cancellable worker client with timeout
ItsWanheda Oct 22, 2026
6499b20
feat: execute regex operations in isolated worker
ItsWanheda Oct 22, 2026
d91b00a
test: add regression coverage for regex engine
ItsWanheda Oct 22, 2026
65a2c9d
Delete REGRESSION_CHECKLIST.md
ItsWanheda Oct 22, 2026
26f625c
ci: run regex regression suite on pushes and pull requests
ItsWanheda Oct 22, 2026
c9f60eb
build: add dependency-free regression test command
ItsWanheda Oct 22, 2026
69d5127
fix: route regex operations through bounded worker
ItsWanheda Oct 22, 2026
9b573bb
feat: expose modern flags and regex stop control
ItsWanheda Oct 22, 2026
25a99f7
test: correct capture-aware split expectation
ItsWanheda Oct 22, 2026
134217b
docs: document worker security and automated tests
ItsWanheda Oct 22, 2026
2ba54f2
fix: validate persisted state and cap favorites
ItsWanheda Oct 22, 2026
5394931
style: add pending and capped-result status states
ItsWanheda Oct 22, 2026
d8a8f5f
docs: record regex hardening release notes
ItsWanheda Oct 22, 2026
c7bedcc
docs: align regression checklist with automated coverage
ItsWanheda Oct 22, 2026
b7c4007
test: assert HTML escaping across highlighted characters
ItsWanheda Oct 22, 2026
d78cf02
fix: preserve empty-text replacements and stop preview work
ItsWanheda Oct 22, 2026
850052d
test: validate browser scripts during regression suite
ItsWanheda Oct 22, 2026
dbb70f7
fix: cancel stale previews on invalid patterns
ItsWanheda Oct 22, 2026
7e0db83
perf: avoid large allocations in text statistics
ItsWanheda Oct 22, 2026
ee6d69d
fix: count whitespace correctly in text statistics
ItsWanheda Oct 22, 2026
c09a924
docs: list supported regex flags
ItsWanheda Oct 22, 2026
c0f2775
docs: place regression checklist under docs
ItsWanheda Oct 22, 2026
7bc1db6
docs: move checklist to avoid deleted-path conflict
ItsWanheda Oct 22, 2026
4706c61
docs: link regression checklist from README
ItsWanheda Oct 22, 2026
44052d5
fix: bound expanded replacement output safely
ItsWanheda Oct 22, 2026
59807df
test: cover replacement expansion resource limits
ItsWanheda Oct 22, 2026
b0d7e14
fix: correct replacement expansion regression test
ItsWanheda Oct 22, 2026
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
23 changes: 23 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Tests

on:
push:
branches: ["main", "fix/regex-regression-hardening"]
pull_request:
workflow_dispatch:

permissions:
contents: read

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Run regression tests
run: npm test
17 changes: 17 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

---

## [1.1.0] - 2026-10-22

### Fixed
- Correct capture data shape and character offsets used by match summaries and group highlighting.
- Advance zero-width matches according to Unicode code-point boundaries.
- Reject duplicate flags and the incompatible u/v flag combination with clear errors.
- Fix file upload and drag-and-drop handling to read the selected File rather than the FileList.
- Fix history removal and validate restored localStorage data before rendering.
- Keep saved empty flags consistent with the flag toggles.

### Added
- Worker-isolated regex matching, replacement, and split operations with a 2.5-second timeout and a manual Stop control.
- Explicit warnings when the match or split result cap is reached.
- Resource limits for pattern/text/replacement/output size and favorites count.
- Automated regression tests and a GitHub Actions test workflow.
- d (indices) and v (Unicode sets) flag toggles.

## [1.0.0] - 2024-08-03

### ✨ Initial Release
Expand Down
56 changes: 37 additions & 19 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Built with pure HTML, CSS & JavaScript — zero dependencies, zero backend, zero

[**Live Demo**](#) · [**Report Bug**](../../issues) · [**Request Feature**](../../issues)

![Version](https://img.shields.io/badge/version-1.0.0-667eea?style=for-the-badge)
![Version](https://img.shields.io/badge/version-1.1.0-667eea?style=for-the-badge)
![License](https://img.shields.io/badge/license-MIT-10b981?style=for-the-badge)
![No Dependencies](https://img.shields.io/badge/dependencies-zero-f472b6?style=for-the-badge)
![Vanilla JS](https://img.shields.io/badge/JS-vanilla-yellow?style=for-the-badge)
Expand All @@ -24,9 +24,12 @@ Built with pure HTML, CSS & JavaScript — zero dependencies, zero backend, zero
### 🎯 Core Engine
- ⚡ **Live matching** as you type — instant feedback, no submit button
- 🎨 **Highlighted matches** with distinct colors for capture groups (supports 6+ groups)
- 🏁 **Flag toggles** for `g`, `i`, `m`, `s`, `u`, `y` plus text input
- 🏁 **Flag toggles** for `d`, `g`, `i`, `m`, `s`, `u`, `v`, `y` plus text input (where supported by the browser)
- 📊 **Detailed match info** — positions, lengths, captured & named groups
- ❌ **Friendly error messages** for invalid regex patterns
- 🛡️ **Worker-isolated execution** with a 2.5-second timeout and a manual Stop control
- 🧯 **Resource limits** for pattern length, text size, matches, split segments, and replacement output
- 🧩 **Correct capture offsets** and Unicode-safe zero-width match advancement
- 📱 **100% responsive** — works beautifully on mobile, tablet & desktop

### 🛠️ Developer Tools
Expand All @@ -39,6 +42,7 @@ Built with pure HTML, CSS & JavaScript — zero dependencies, zero backend, zero
### 💾 Persistence
- 🕒 **History** — last 20 patterns auto-saved to `localStorage`
- ⭐ **Favorites** — star your best patterns for quick access
- 🧹 **Validated stored state** — malformed history and favorites are normalized before rendering
- 💿 **Auto-save** — your work persists across page reloads
- 📂 **Drag & drop** text files (up to 5MB) directly into the editor

Expand All @@ -52,34 +56,27 @@ Built with pure HTML, CSS & JavaScript — zero dependencies, zero backend, zero

## 🚀 Quick Start

### Option 1: Direct Open
**Use a local HTTP server.** Regex Pro evaluates patterns inside a Web Worker; opening `index.html` directly with `file://` can prevent the worker and shared core from loading.

```bash
# Clone the repository
git clone https://github.com/ItsWanheda/regex-pro.git

# Navigate to the folder
cd regex-pro

# Open in your browser
open index.html # macOS
xdg-open index.html # Linux
start index.html # Windows
```
### Option 2: Local Server (Recommended)
```bash
# Using Python 3
# Python 3 (built-in; no dependencies)
python -m http.server 8000
```
Then visit http://localhost:8000/src/

# Using Node.js
### Alternative static servers

```bash
# Node.js
npx serve .

# Using PHP
# PHP
php -S localhost:8000
```
Then visit http://localhost:8000
> A local server is recommended to enable drag-and-drop and avoid any browser file-protocol restrictions.

---

## 🎹 Keyboard Shortcuts

Expand Down Expand Up @@ -132,6 +129,27 @@ Then visit http://localhost:8000

---

## 🧪 Automated Tests

The project keeps zero runtime dependencies. With Node.js 18 or later installed, run:

```bash
npm test
```

The regression suite covers capture offsets, named and unmatched groups, zero-width and Unicode behavior, flag validation, partial-result warnings, worker timeout termination, HTML escaping, persistence recovery, replacement, and split behavior. GitHub Actions runs the suite on pushes and pull requests. See the [regression checklist](./docs/REGRESSION_CHECKLIST.md) for the full scenario list.

### Safety limits
- Pattern: 10,000 characters maximum
- Test text: 5,000,000 characters maximum
- Matches and split segments: 50,000 each
- Replacement input: 10,000 characters maximum
- Worker evaluation timeout: 2.5 seconds for UI operations

A timeout terminates the worker so pathological patterns cannot indefinitely block the page's main thread. These limits reduce resource-exhaustion risk but cannot guarantee every pattern will finish within the time budget.

---

## 🤝 Contributing
Contributions make the open source community an amazing place to learn, inspire, and create. Any contribution you make is **greatly appreciated**.

Expand Down
21 changes: 0 additions & 21 deletions REGRESSION_CHECKLIST.md

This file was deleted.

20 changes: 20 additions & 0 deletions docs/REGRESSION_CHECKLIST.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Regression Checklist

**Automation coverage:** 10/10 requested regression scenarios are represented in `tests/regex-core.test.js`. A checked item means an automated regression assertion has been added; it does not imply the latest CI run passed.

## Regex engine and UI regressions

- [x] **Capture offsets** — Verify `/(a)(b)/` highlights both capture groups at the correct positions.
- [x] **Named groups** — Verify `/(?<word>hello)/` produces the correct named-group data.
- [x] **Unmatched groups** — Verify `/(a)?b/` handles the absent capture without errors.
- [x] **Zero-width matches** — Verify `/^/gm` terminates and reports each expected line boundary.
- [x] **Unicode boundaries** — Verify zero-width matches with `/u` do not split surrogate pairs.
- [x] **Invalid flags** — Reject duplicate flags and incompatible combinations with a useful error.
- [x] **Large match counts** — Verify the match cap produces an explicit partial-results warning.
- [x] **ReDoS responsiveness** — Verify the worker client terminates a non-responsive worker when the timeout expires.
- [x] **HTML injection** — Verify user text containing HTML is rendered as escaped text, not executable markup.
- [x] **Persistence recovery** — Verify malformed stored history and favorites safely fall back to normalized defaults.

## Verification

Run `npm test` with Node.js 18 or later. GitHub Actions runs the same suite on pushes and pull requests. Treat the latest workflow result as the test pass/fail status; checkmarks above track coverage, not successful execution.
12 changes: 12 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "regex-pro",
"version": "1.1.0",
"private": true,
"description": "A zero-runtime-dependency browser regex tester with worker-isolated evaluation",
"scripts": {
"test": "node --check src/Script/script.js && node --check src/Script/regex-core.js && node --check src/Script/regex-worker-client.js && node --check src/Script/regex-worker.js && node --test tests/*.test.js"
},
"engines": {
"node": ">=18"
}
}
Loading
Loading