Repository: JuliaLang/julia
File: src/rtutils.c (C)

Code before:
                special = 1;
                break;
            }
        }
        if (!special) {
            jl_uv_puts(out, str, len);
            n += len;
        }
        else if (raw) {
            // REF: Base.escape_raw_string
            int escapes = 0;
            for (size_t i = 0; i < len; i++) {
                uint8_t c = str[i];
                if (c == '\\') {
                    escapes++;
                }
                else {
                     if (c == '"')
                         for (escapes++; escapes > 0; escapes--)
                             jl_uv_puts(out, "\\", 1);
                     escapes = 0;
                }
                jl_uv_puts(out, str + i, 1);
            }
            for (; escapes > 0; escapes--)
                jl_uv_puts(out, "\\", 1);
        }
        else {
            char buf[512];
            size_t i = 0;
            while (i < len) {
                size_t r = u8_escape(buf, sizeof(buf), str, &i, len, "\"$", 0);
                jl_uv_puts(out, buf, r - 1);
                n += r - 1;
            }
        }
    }
    if (wrap)
        n += jl_printf(out, "\"");
    return n;
}

static int jl_is_quoted_sym(const char *sn)
{
    static const char *const quoted_syms[] = {":", "::", ":=", "=", "==", "===", "=>", "`"};
    for (int i = 0; i < sizeof quoted_syms / sizeof *quoted_syms; i++)
        if (!strcmp(sn, quoted_syms[i]))
            return 1;
    return 0;
}


Review comment (security):
```suggestion
                             n += jl_uv_puts(out, "\\", 1);
                     escapes = 0;
                }
                n += jl_uv_puts(out, str + i, 1);
            }
            for (; escapes > 0; escapes--)
                n += jl_uv_puts(out, "\\", 1);
```

Code after:
                special = 1;
                break;
            }
        }
        if (!special) {
            jl_uv_puts(out, str, len);
            n += len;
        }
        else if (raw) {
            // REF: Base.escape_raw_string
            int escapes = 0;
            for (size_t i = 0; i < len; i++) {
                uint8_t c = str[i];
                if (c == '\\') {
                    escapes++;
                }
                else {
                     if (c == '"')
                         for (escapes++; escapes > 0; escapes--)
                             n += jl_printf(out, "\\");
                     escapes = 0;
                }
                n += jl_printf(out, "%c", str[i]);
            }
            for (; escapes > 0; escapes--)
                n += jl_printf(out, "\\");
        }
        else {
            char buf[512];
            size_t i = 0;
            while (i < len) {
                size_t r = u8_escape(buf, sizeof(buf), str, &i, len, "\"$", 0);
                jl_uv_puts(out, buf, r - 1);
                n += r - 1;
            }
        }
    }
    if (wrap)
        n += jl_printf(out, "\"");
    return n;
}

static int jl_is_quoted_sym(const char *sn)
{
    static const char *const quoted_syms[] = {":", "::", ":=", "=", "==", "===", "=>", "`"};
    for (int i = 0; i < sizeof quoted_syms / sizeof *quoted_syms; i++)
        if (!strcmp(sn, quoted_syms[i]))
            return 1;
    return 0;
}