Skip to content

fix - #8

Merged
djzet merged 1 commit into
mainfrom
sea
Aug 21, 2026
Merged

fix#8
djzet merged 1 commit into
mainfrom
sea

Conversation

@djzet

@djzet djzet commented Aug 21, 2026 •

Copy link
Copy Markdown
Owner

Summary by Sourcery

Improve coordinate input and sharing robustness while making cursor coordinate rendering safer.

Bug Fixes:

  • Support comma-based decimal input for map coordinates.
  • Keep share notifications functional when the map container is unavailable.
  • Render cursor coordinates as text nodes to avoid interpreting coordinate content as HTML.

CI:

  • Remove emoji characters from static deployment workflow messages.

@sourcery-ai

sourcery-ai Bot commented Aug 21, 2026 •

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR removes emoji/log-symbol usage from CI logs, improves numeric parsing of point coordinates with locale-agnostic handling, hardens toast creation when the expected container is missing, and refactors cursor coordinate rendering to use safe DOM APIs instead of innerHTML.

Sequence diagram for locale-agnostic point parsing

sequenceDiagram
    participant UserInput as User
    participant AppPoints as AppPoints
    participant readPoint as readPoint

    UserInput->>AppPoints: set ix.value, iy.value
    AppPoints->>readPoint: readPoint(ix, iy)
    activate readPoint
    readPoint->>readPoint: String(ix.value).replace(',', '.')
    readPoint->>readPoint: parseFloat(gx)
    readPoint->>readPoint: String(iy.value).replace(',', '.')
    readPoint->>readPoint: parseFloat(gy)
    alt [isNaN(gx) or isNaN(gy)]
        readPoint-->>AppPoints: null
    else
        readPoint-->>AppPoints: { x: gx, y: gy, ... }
    end
    deactivate readPoint
Loading

Sequence diagram for toast creation with fallback container

sequenceDiagram
    participant AppShare as AppShare
    participant document as document
    participant toast as toastDiv

    AppShare->>AppShare: showToast(message, type)
    alt [toast element exists]
        AppShare->>toast: update textContent, className
    else [toast element missing]
        AppShare->>document: createElement('div')
        document-->>AppShare: toastDiv
        AppShare->>toast: set id, className
        AppShare->>document: querySelector('.map-wrap')
        alt [wrap found]
            document-->>AppShare: wrap
        else [wrap missing]
            document-->>AppShare: body
        end
        AppShare->>wrap: appendChild(toastDiv)
        AppShare->>toast: set textContent, className
    end
Loading

Sequence diagram for safe cursor coordinate rendering

sequenceDiagram
    participant MapInt as MapInteractions
    participant utils as utils
    participant cursor as cursorCoords

    MapInt->>MapInt: handleMouseMove(p, view)
    MapInt->>document: getElementById('cursorCoords')
    document-->>MapInt: cursorCoords
    alt [cursorCoords exists]
        MapInt->>utils: screenToWorld(p.x, p.y, view)
        utils-->>MapInt: wpt
        MapInt->>cursor: set textContent = ''
        MapInt->>document: createElement('span')
        document-->>MapInt: xSpan
        MapInt->>xSpan: set textContent = 'x' + utils.gameCoord(wpt.x)
        MapInt->>document: createElement('span')
        document-->>MapInt: ySpan
        MapInt->>ySpan: set textContent = 'y' + utils.gameCoord(wpt.y)
        MapInt->>cursor: appendChild(xSpan)
        MapInt->>cursor: appendChild(ySpan)
    end
Loading

File-Level Changes

Change Details Files
Normalize CI logging messages to avoid emojis or special symbols.
  • Updated success log message when Supabase credentials are injected to use plain ASCII text.
  • Updated warning log message when secrets are not found to use plain ASCII text.
.github/workflows/static.yml
Make point coordinate parsing tolerant of comma decimal separators.
  • Wrap input values in String() before parsing to avoid unexpected types.
  • Replace commas with dots in coordinate strings before calling parseFloat, allowing users to enter either 1.23 or 1,23.
js/features/points.js
Harden share toast rendering to avoid errors when the map container is missing and normalize IIFE style.
  • Adjusted AppShare IIFE declaration spacing for consistency with other modules.
  • Fallback to document.body as a parent when .map-wrap is not present before appending the toast element.
js/features/share.js
Render cursor coordinates using safe DOM node creation instead of innerHTML.
  • Clear existing cursorCoords content by resetting textContent before inserting new elements.
  • Create separate span elements for x and y values with textContent instead of injecting an HTML string.
  • Append the newly created span elements to the cursorCoords container to avoid potential XSS and layout issues.
js/map/interactions.js

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue, and left some high level feedback:

Fixed security issues:

  • Cross-site scripting (XSS) via untrusted HTML/JS injection in web rendering sinks (link)

  • The coordinate parsing in readPoint is now duplicated for gx and gy; consider extracting a small helper (e.g. parseLocalizedFloat(input)) to keep this logic in one place and easier to reuse or adjust.

  • In updateCursorCoords, new span elements are created and appended on every mouse move; you could improve performance by creating the spans once and only updating their textContent.

Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The coordinate parsing in `readPoint` is now duplicated for `gx` and `gy`; consider extracting a small helper (e.g. `parseLocalizedFloat(input)`) to keep this logic in one place and easier to reuse or adjust.
- In `updateCursorCoords`, new span elements are created and appended on every mouse move; you could improve performance by creating the spans once and only updating their `textContent`.

## Individual Comments

### Comment 1
<location path="js/map/interactions.js" line_range="115-121" />
<code_context>
         if (cursorCoords) {
             const wpt = utils.screenToWorld(p.x, p.y, view);
-            cursorCoords.innerHTML = `<span>x${utils.gameCoord(wpt.x)}</span><span>y${utils.gameCoord(wpt.y)}</span>`;
+            cursorCoords.textContent = '';
+            const xSpan = document.createElement('span');
+            xSpan.textContent = `x${utils.gameCoord(wpt.x)}`;
+            const ySpan = document.createElement('span');
+            ySpan.textContent = `y${utils.gameCoord(wpt.y)}`;
+            cursorCoords.appendChild(xSpan);
+            cursorCoords.appendChild(ySpan);
             const wrap = canvas.parentElement.getBoundingClientRect();
             let lx = p.x + 14;
</code_context>
<issue_to_address>
**suggestion (performance):** Avoid allocating new span elements on every mouse move to reduce DOM churn.

Since this runs on every mouse move, repeatedly creating and appending new spans can add unnecessary DOM churn and GC pressure. Consider creating the spans once and just updating their `textContent` to improve responsiveness, particularly on lower-end devices.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread js/map/interactions.js
Comment on lines +115 to +121
cursorCoords.textContent = '';
const xSpan = document.createElement('span');
xSpan.textContent = `x${utils.gameCoord(wpt.x)}`;
const ySpan = document.createElement('span');
ySpan.textContent = `y${utils.gameCoord(wpt.y)}`;
cursorCoords.appendChild(xSpan);
cursorCoords.appendChild(ySpan);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (performance): Avoid allocating new span elements on every mouse move to reduce DOM churn.

Since this runs on every mouse move, repeatedly creating and appending new spans can add unnecessary DOM churn and GC pressure. Consider creating the spans once and just updating their textContent to improve responsiveness, particularly on lower-end devices.

@djzet
djzet merged commit a792170 into main Aug 21, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant