Implemented changes to add support for HTML templates#199
Implemented changes to add support for HTML templates#199irsheep wants to merge 13 commits intoAndrewPaglusch:masterfrom
Conversation
Signed-off-by: Luis Tavares <49619346+irsheep@users.noreply.github.com>
|
This looks really neat! I'll go ahead and review this with @mattburchett and see if we can get it merged. Thank you! |
There was a problem hiding this comment.
Pull Request Overview
This PR adds HTML template support to FlashPaper, allowing users to create structured forms with various input types (radio buttons, select boxes, date/time pickers, etc.) for secrets instead of plain text. The feature includes client-side template loading via AJAX, server-side rendering of templates, and API support for HTML-based secrets.
- Implements client-side template loading with error handling and dynamic form rendering
- Adds server-side template parsing and HTML generation for both viewing and editing modes
- Extends the API to support HTML template-based secrets with special handling for
HTML_FORM_SECRETmarker
Reviewed Changes
Copilot reviewed 11 out of 12 changed files in this pull request and generated 12 comments.
Show a summary per file
| File | Description |
|---|---|
| js/templates.js | Client-side template loading, form rendering, and AJAX utilities |
| js/flashpaper.js | HTTPS warning banner, HTML form detection, and form element resizing logic |
| index.php | Server-side processing to handle HTML form secrets on submission and retrieval |
| includes/functions.php | Template HTML generation with input type support and file parsing utilities |
| img/copy.svg | Copy icon SVG for individual field copy buttons |
| html/view_secret_html.php | View template for displaying HTML-based secrets |
| html/submit_secret.php | Updated submit form with template selector and content container |
| html/header.php | Added CSS/JS includes, moved inline scripts to external files, added error overlay |
| css/table.css | Styling for HTML form elements, animations, and overlay |
| ajax.php | AJAX endpoint for template loading |
| README.md | Documentation for HTML templates feature and API usage |
Comments suppressed due to low confidence (1)
includes/functions.php:1
- Potential undefined index error if 'secret' key doesn't exist in
$formdataarray. Should useisset()or null coalescing operator to check if the key exists before accessing it.
<?php
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
js/flashpaper.js
Outdated
| if (typeof type === 'undefined') {type = null;} | ||
|
|
||
| var element = null; | ||
| var text = null; |
There was a problem hiding this comment.
Use let or const instead of var for block-scoped variable declarations, consistent with modern JavaScript best practices and the rest of the codebase.
| var text = null; | |
| let text = null; |
includes/functions.php
Outdated
| foreach (get_all_lines($file_handle) as $line) { | ||
| // Get the name, element and propeties to create the HTML elements | ||
| preg_match( | ||
| '/(?<name>.+):\s+(?<element>radio|select|number|textarea|datetime|date|time|datetime|checkbox)?(\((?<props>.+)?\))?/', |
There was a problem hiding this comment.
The word 'datetime' appears twice in the regex pattern, which is redundant. Remove the duplicate occurrence.
|
@irsheep I had Copilot do an initial review for some low-hanging fruit like typos and other small things. Would you mind addressing the above items it found? I'll do a full review as soon as I find some free time. |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Luis Tavares <49619346+irsheep@users.noreply.github.com>
Signed-off-by: Luis Tavares <49619346+irsheep@users.noreply.github.com>
| $filename = basename($t, '.txt'); | ||
| $url_filename = urlencode($filename); | ||
| echo "<option value=\"?t={$url_filename}\">{$filename}</option>"; | ||
| echo "<option value=\"{$url_filename}\">{$filename}</option>"; |
There was a problem hiding this comment.
The ability to include the template as part of the URL is something I personally use quite often. I would imagine this is used by others as well. It's useful for sending a template URL to someone to have them fill out and send back
There was a problem hiding this comment.
This feature is still available, but there was an weird behaviour when ?t= was used, also now when specifying the template the combo box is updated with the name of the template.
Signed-off-by: Luis Tavares <49619346+irsheep@users.noreply.github.com>
|
Hey @irsheep, I finally got around to doing a deeper review of this PR and I found a stored XSS vulnerability that we'll need to address before merging. The What makes this worse is that any regular text secret can trigger the HTML form rendering path. There's no special flag or marker in the database. It just checks if the decrypted secret content contains Here's how to reproduce:
JavaScript executes automatically, and you'll get an The I think there are two things that need to happen to fix this:
Let me know if you have any questions or if you'd like to talk through the fix. Thanks! |
Added error handling when parsing HTML form Removed the requirement for HTML_FORM_SECRET Signed-off-by: Luis Tavares <49619346+irsheep@users.noreply.github.com>
|
Hi, HTML values are now escaped for html special characters, when viewing the secret message. I tried to implement a better way of identifying a HTML secret, but unless the templates are placed on a different directory, have a different extension, I can't think of another way to distinguish them without parsing the content and checking the contents of the template. But I have removed the requirement of the |
Added the functionality to create a template using HTML elements, this allows the user to create a basic form.